summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Evans <grknight@gentoo.org>2020-10-02 15:24:06 -0400
committerBrian Evans <grknight@gentoo.org>2020-10-02 15:24:06 -0400
commit60dd5fd95847643eab04ce173f0774c9c584e795 (patch)
tree52299ac4e3c5c69df75997bfd7d62b71ef9e0089 /MLEB/Translate/utils/MessageGroupStatsRebuildJob.php
parentUpdate Widgets to 1.35 (diff)
downloadextensions-60dd5fd95847643eab04ce173f0774c9c584e795.tar.gz
extensions-60dd5fd95847643eab04ce173f0774c9c584e795.tar.bz2
extensions-60dd5fd95847643eab04ce173f0774c9c584e795.zip
Update MLEB to 2020.07
Signed-off-by: Brian Evans <grknight@gentoo.org>
Diffstat (limited to 'MLEB/Translate/utils/MessageGroupStatsRebuildJob.php')
-rw-r--r--MLEB/Translate/utils/MessageGroupStatsRebuildJob.php36
1 files changed, 32 insertions, 4 deletions
diff --git a/MLEB/Translate/utils/MessageGroupStatsRebuildJob.php b/MLEB/Translate/utils/MessageGroupStatsRebuildJob.php
index d6d3b448..e813d614 100644
--- a/MLEB/Translate/utils/MessageGroupStatsRebuildJob.php
+++ b/MLEB/Translate/utils/MessageGroupStatsRebuildJob.php
@@ -8,7 +8,7 @@
*/
/**
- * Job for rebuilding message index.
+ * Job for rebuilding message group stats.
*
* @ingroup JobQueue
*/
@@ -23,6 +23,20 @@ class MessageGroupStatsRebuildJob extends Job {
}
/**
+ * Force updating of message group stats for given groups.
+ *
+ * This uses cache for groups not given. If given groups have dependencies such
+ * as an aggregate group and it's subgroup, this attempts to take care of it so
+ * that no duplicate work is done.
+ *
+ * @param string[] $messageGroupIds
+ * @return self
+ */
+ public static function newRefreshGroupsJob( array $messageGroupIds ) {
+ return new self( Title::newMainPage(), [ 'cleargroups' => $messageGroupIds ] );
+ }
+
+ /**
* @param Title $title
* @param array $params
*/
@@ -34,15 +48,29 @@ class MessageGroupStatsRebuildJob extends Job {
$params = $this->params;
$flags = 0;
+ // Sanity check that this is run via JobQueue. Immediate writes are only safe when they
+ // are run in isolation, e.g. as a separate job in the JobQueue.
+ if ( defined( 'MEDIAWIKI_JOB_RUNNER' ) ) {
+ $flags |= MessageGroupStats::FLAG_IMMEDIATE_WRITES;
+ }
+
+ // This is to make sure the priority value is not read from the process cache.
+ // There is still a possibility that, due to replication lag, an old value is read.
+ MessageGroups::singleton()->clearProcessCache();
+
if ( isset( $params[ 'purge' ] ) && $params[ 'purge' ] ) {
$flags |= MessageGroupStats::FLAG_NO_CACHE;
}
if ( isset( $params[ 'groupid' ] ) ) {
MessageGroupStats::forGroup( $params[ 'groupid' ], $flags );
- }
- if ( isset( $params[ 'languagecode' ] ) ) {
- MessageGroupStats::forGroup( $params[ 'languagecode' ], $flags );
+ } elseif ( isset( $params[ 'cleargroups' ] ) ) {
+ // clearGroup takes an array of group ids, but no flags
+ MessageGroupStats::clearGroup( $params[ 'cleargroups' ] );
+ } elseif ( isset( $params[ 'languagecode' ] ) ) {
+ MessageGroupStats::forLanguage( $params[ 'languagecode' ], $flags );
+ } else {
+ throw new InvalidArgumentException( 'No groupid or languagecode or cleargroup provided' );
}
return true;