27 parent::__construct( __CLASS__, $title, $params );
28 $this->removeDuplicates =
true;
39 MediaWikiServices::getInstance()->getJobQueueGroup()->push( $job );
48 public static function newJob( $title ) {
49 $job =
new self( $title );
54 public function run() {
55 $lb = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
56 if ( !$lb->waitForReplication() ) {
57 $this->logWarning(
'Continuing despite replication lag' );
60 $title = $this->title;
62 $code = $handle->getCode();
64 if ( !$code && !$handle->isValid() ) {
68 $groups = self::getGroupsWithTransitions( $handle );
69 $messageGroupReview = Services::getInstance()->getMessageGroupReview();
70 foreach ( $groups as $id => $transitions ) {
75 $messageGroupReview->changeState( $group, $code, $state, FuzzyBot::getUser() );
82 public static function getGroupsWithTransitions(
MessageHandle $handle ) {
92 $conds = $group->getMessageGroupStates()->getConditions();
94 $listeners[$id] = $conds;
101 public static function getStatValue( $stats, $type ) {
109 return $total - $translated - $outdated;
117 throw new MWException(
"Unknown condition $type" );
121 public static function matchCondition( $value, $condition, $max ) {
122 switch ( $condition ) {
128 return $value === $max;
130 throw new MWException(
"Unknown condition value $condition" );
141 foreach ( $transitions as $transition ) {
142 [ $newState, $conds ] = $transition;
145 foreach ( $conds as $type => $cond ) {
146 $statValue = self::getStatValue( $stats, $type );
147 $max = $stats[MessageGroupStats::TOTAL];
148 $match = $match && self::matchCondition( $statValue, $cond, $max );