Glaisher has uploaded a new change for review. https://gerrit.wikimedia.org/r/282378
Change subject: Improve translation statistics regeneration ...................................................................... Improve translation statistics regeneration * Rebuild message index in TranslationsUpdateJob * Recalculate statistics when a page is marked for translation Translation statistics need to be reset when page is marked for translation with units invalidation enabled. * Allow recalculating statistics with null edits No reason to disallow this as sometimes the stats are not up-to-date after translations. * Don't run onSectionSave() changes for FuzzyBot edits This causes FuzzyBot to clear the message group stats several times for /en and also unnecessary TranslateRenderJobs when pages are marked for translation. These updates are now done within the TranslationsUpdateJob Bug: T104172 Bug: T102229 Bug: T106262 Change-Id: I48626647ebe08f822b149175b02e860bae50e1b2 --- M Translate.php M tag/PageTranslationHooks.php M tag/SpecialPageTranslation.php M utils/TranslationsUpdateJob.php 4 files changed, 20 insertions(+), 11 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Translate refs/changes/78/282378/1 diff --git a/Translate.php b/Translate.php index 187adc7..9d336b8 100644 --- a/Translate.php +++ b/Translate.php @@ -154,7 +154,6 @@ $wgHooks['MakeGlobalVariablesScript'][] = 'TranslateHooks::addConfig'; // Internal event listeners -$wgHooks['TranslateEventTranslationEdit'][] = 'MessageGroupStats::clear'; $wgHooks['TranslateEventTranslationReview'][] = 'MessageGroupStats::clear'; $wgHooks['TranslateEventTranslationEdit'][] = 'MessageGroupStatesUpdaterJob::onChange'; $wgHooks['TranslateEventTranslationReview'][] = 'MessageGroupStatesUpdaterJob::onChange'; diff --git a/tag/PageTranslationHooks.php b/tag/PageTranslationHooks.php index 53d1b81..b9a2693 100644 --- a/tag/PageTranslationHooks.php +++ b/tag/PageTranslationHooks.php @@ -121,6 +121,11 @@ return true; } + // FuzzyBot may do some duplicate work already worked on by other jobs + if ( FuzzyBot::getName() === $user->getName() ) { + return true; + } + // Some checks $handle = new MessageHandle( $title ); @@ -142,6 +147,10 @@ // Finally we know the title and can construct a Translatable page $page = TranslatablePage::newFromTitle( $group->getTitle() ); + // Update translation stats + MessageGroupStats::clear( $handle ); + MessageGroupStats::forGroup( $page->getMessageGroupId() ); + // Update the target translation page if ( !$handle->isDoc() ) { $code = $handle->getCode(); @@ -155,7 +164,7 @@ $code, $user, $flags, $summary ) { $source = $page->getTitle(); - $target = Title::makeTitle( $source->getNamespace(), $source->getDBkey() . "/$code" ); + $target = $source->getSubpage( $code ); // We don't know and don't care $flags &= ~EDIT_NEW & ~EDIT_UPDATE; @@ -167,19 +176,14 @@ $job->setFlags( $flags ); $job->run(); - // Regenerate translation caches - $page->getTranslationPercentages( 'force' ); - - // Invalidate caches + // Invalidate caches so that language bar is up-to-date $pages = $page->getTranslationPages(); foreach ( $pages as $title ) { $wikiPage = WikiPage::factory( $title ); $wikiPage->doPurge(); } - - // And the source page itself too - $wikiPage = WikiPage::factory( $page->getTitle() ); - $wikiPage->doPurge(); + $sourceWikiPage = WikiPage::factory( $source ); + $sourceWikiPage->doPurge(); } /** diff --git a/tag/SpecialPageTranslation.php b/tag/SpecialPageTranslation.php index 2c4297d..20db4ee 100644 --- a/tag/SpecialPageTranslation.php +++ b/tag/SpecialPageTranslation.php @@ -907,7 +907,6 @@ // Clear more caches $page->getTitle()->invalidateCache(); - MessageIndexRebuildJob::newJob()->insert(); return false; } diff --git a/utils/TranslationsUpdateJob.php b/utils/TranslationsUpdateJob.php index 78c5193..38104bb 100644 --- a/utils/TranslationsUpdateJob.php +++ b/utils/TranslationsUpdateJob.php @@ -30,6 +30,13 @@ $job->run(); } + MessageIndex::singleton()->rebuild(); + + // Refresh language statistics + $id = $this->page->getMessageGroupId(); + MessageGroupStats::clearGroup( $id ); + MessageGroupStats::forGroup( $id ); + $wikiPage = WikiPage::factory( $this->page->getTitle() ); $wikiPage->doPurge(); -- To view, visit https://gerrit.wikimedia.org/r/282378 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I48626647ebe08f822b149175b02e860bae50e1b2 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Translate Gerrit-Branch: master Gerrit-Owner: Glaisher <glaisher.w...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits