summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'MLEB/Translate/scripts/refresh-translatable-pages.php')
-rw-r--r--MLEB/Translate/scripts/refresh-translatable-pages.php30
1 files changed, 23 insertions, 7 deletions
diff --git a/MLEB/Translate/scripts/refresh-translatable-pages.php b/MLEB/Translate/scripts/refresh-translatable-pages.php
index 37021e12..7fe536f9 100644
--- a/MLEB/Translate/scripts/refresh-translatable-pages.php
+++ b/MLEB/Translate/scripts/refresh-translatable-pages.php
@@ -3,7 +3,7 @@
* Script to ensure all translation pages are up to date.
*
* @author Niklas Laxström
- * @license GPL-2.0+
+ * @license GPL-2.0-or-later
* @file
*/
@@ -24,10 +24,14 @@ class RefreshTranslatablePages extends Maintenance {
public function __construct() {
parent::__construct();
$this->mDescription = 'Ensure all translation pages are up to date.';
+ $this->setBatchSize( 300 );
+ $this->addOption( 'jobqueue', 'Use JobQueue (asynchronous)' );
}
public function execute() {
$groups = MessageGroups::singleton()->getGroups();
+ $counter = 0;
+ $useJobQueue = $this->hasOption( 'jobqueue' );
/** @var MessageGroup $group */
foreach ( $groups as $group ) {
@@ -35,15 +39,27 @@ class RefreshTranslatablePages extends Maintenance {
continue;
}
- // Get all translation subpages and refresh each one of them
- $page = TranslatablePage::newFromTitle( $group->getTitle() );
- $translationPages = $page->getTranslationPages();
+ $counter++;
+ if ( ( $counter % $this->mBatchSize ) === 0 ) {
+ wfWaitForSlaves();
+ }
- foreach ( $translationPages as $subpage ) {
- $job = TranslateRenderJob::newJob( $subpage );
- $job->run();
+ $page = TranslatablePage::newFromTitle( $group->getTitle() );
+ $jobs = TranslationsUpdateJob::getRenderJobs( $page );
+ if ( $useJobQueue ) {
+ JobQueueGroup::singleton()->push( $jobs );
+ } else {
+ foreach ( $jobs as $job ) {
+ $job->run();
+ }
}
}
+
+ if ( $useJobQueue ) {
+ $this->output( "Queued refresh for $counter translatable pages.\n" );
+ } else {
+ $this->output( "Refreshed $counter translatable pages.\n" );
+ }
}
}