Nikerabbit has uploaded a new change for review.
https://gerrit.wikimedia.org/r/283172
Change subject: Clear WikiPageMessageGroup caches when page is marked for
translation
......................................................................
Clear WikiPageMessageGroup caches when page is marked for translation
MessageIndex and stats would go stale if JobQueue runs two
TranslationsUpdateJobs in same process, because then the
definitions would stay cached in the member variable of
WikiPageMessageGroup. While this kind of setup is uncommon,
most run jobqueue during web requests or cron, with the
--wait option or if lots of jobs are queue this can happen.
Test plan:
* Configure jobs to only be processed manually
* Run php maintenance/runJobs.php --wait
* Mark page for translation
* Do some translations for it
* Do changes to the page (add new messages)
* Mark the page for translation again
Without this patch the total number of messages would be stale.
Change-Id: Ib5b87f9807fb36a232800e08d3647395ebd0bb5c
---
M messagegroups/WikiPageMessageGroup.php
M utils/TranslationsUpdateJob.php
2 files changed, 15 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Translate
refs/changes/72/283172/1
diff --git a/messagegroups/WikiPageMessageGroup.php
b/messagegroups/WikiPageMessageGroup.php
index 33ab455..76db9b8 100644
--- a/messagegroups/WikiPageMessageGroup.php
+++ b/messagegroups/WikiPageMessageGroup.php
@@ -83,6 +83,18 @@
return $this->definitions = $new_defs;
}
+ /**
+ * Clear caches to avoid stale data.
+ *
+ * For example JobQueue can run for a longer time, and stale
definitions would
+ * cause the total number of messages to be incorrect.
+ *
+ * @since 2016.04
+ */
+ public function clearCaches() {
+ $this->definitions = null;
+ }
+
public function load( $code ) {
if ( $this->isSourceLanguage( $code ) ) {
return $this->getDefinitions();
diff --git a/utils/TranslationsUpdateJob.php b/utils/TranslationsUpdateJob.php
index 44ad251..6150e32 100644
--- a/utils/TranslationsUpdateJob.php
+++ b/utils/TranslationsUpdateJob.php
@@ -30,6 +30,9 @@
$job->run();
}
+ // Ensure fresh definitions for MessageIndex and stats
+ $this->page->getMessageGroup()->clearCaches();
+
MessageIndex::singleton()->rebuild();
// Refresh translations statistics
--
To view, visit https://gerrit.wikimedia.org/r/283172
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib5b87f9807fb36a232800e08d3647395ebd0bb5c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Translate
Gerrit-Branch: master
Gerrit-Owner: Nikerabbit <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits