diff options
Diffstat (limited to 'MLEB/Translate/tag/TranslateRenderJob.php')
-rw-r--r-- | MLEB/Translate/tag/TranslateRenderJob.php | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/MLEB/Translate/tag/TranslateRenderJob.php b/MLEB/Translate/tag/TranslateRenderJob.php index a8ccf3c0..27fe1366 100644 --- a/MLEB/Translate/tag/TranslateRenderJob.php +++ b/MLEB/Translate/tag/TranslateRenderJob.php @@ -7,12 +7,15 @@ * @license GPL-2.0-or-later */ +use MediaWiki\Extensions\Translate\Jobs\GenericTranslateJob; +use MediaWiki\Extensions\Translate\SystemUsers\FuzzyBot; + /** * Job for updating translation pages when translation or template changes. * * @ingroup PageTranslation JobQueue */ -class TranslateRenderJob extends Job { +class TranslateRenderJob extends GenericTranslateJob { /** * @param Title $target @@ -33,21 +36,23 @@ class TranslateRenderJob extends Job { */ public function __construct( $title, $params = [] ) { parent::__construct( __CLASS__, $title, $params ); - $this->params = $params; $this->removeDuplicates = true; } public function run() { global $wgTranslateKeepOutdatedTranslations; + $this->logInfo( 'Starting TranslateRenderJob' ); + // Initialization $title = $this->title; - list( , $code ) = TranslateUtils::figureMessage( $title->getPrefixedText() ); + [ , $code ] = TranslateUtils::figureMessage( $title->getPrefixedText() ); // Return the actual translation page... $page = TranslatablePage::isTranslationPage( $title ); if ( !$page ) { - throw new MWException( "Cannot render translation page for {$title->getPrefixedText()}!" ); + $this->logError( 'Cannot render translation page!' ); + return false; } $group = $page->getMessageGroup(); @@ -68,10 +73,21 @@ class TranslateRenderJob extends Job { // @todo FuzzyBot hack PageTranslationHooks::$allowTargetEdit = true; $content = ContentHandler::makeContent( $text, $page->getTitle() ); - $page->doEditContent( $content, $summary, $flags, false, $user ); + $editStatus = $page->doEditContent( $content, $summary, $flags, false, $user ); + if ( !$editStatus->isOK() ) { + $this->logError( + 'Error while editing content in page.', + [ + 'content' => $content, + 'errors' => $editStatus->getErrors() + ] + ); + } + $this->logInfo( 'Finished page edit operation' ); PageTranslationHooks::$allowTargetEdit = false; + $this->logInfo( 'Finished TranslateRenderJob' ); return true; } |