28 parent::__construct( __CLASS__, $title, $params );
29 $this->removeDuplicates =
true;
39 $job = self::newJob( $handle->
getTitle() );
40 MediaWikiServices::getInstance()->getJobQueueGroup()->push( $job );
49 public static function newJob( $title ) {
50 $job =
new self( $title );
55 public function run() {
56 $lb = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
57 if ( !$lb->waitForReplication() ) {
58 $this->logWarning(
'Continuing despite replication lag' );
61 $title = $this->title;
63 $code = $handle->getCode();
65 if ( !$code && !$handle->isValid() ) {
69 $groups = self::getGroupsWithTransitions( $handle );
70 $messageGroupReview = Services::getInstance()->getMessageGroupReview();
71 foreach ( $groups as $id => $transitions ) {
72 $group = MessageGroups::getGroup( $id );
74 $state = self::getNewState( $stats, $transitions );
76 $messageGroupReview->changeState( $group, $code, $state, FuzzyBot::getUser() );
83 public static function getGroupsWithTransitions(
MessageHandle $handle ) {
86 $group = MessageGroups::getGroup( $id );
93 $conds = $group->getMessageGroupStates()->getConditions();
95 $listeners[$id] = $conds;
102 public static function getStatValue( $stats, $type ) {
110 return $total - $translated - $outdated;
118 throw new MWException(
"Unknown condition $type" );
122 public static function matchCondition( $value, $condition, $max ) {
123 switch ( $condition ) {
129 return $value === $max;
131 throw new MWException(
"Unknown condition value $condition" );
142 foreach ( $transitions as $transition ) {
143 [ $newState, $conds ] = $transition;
146 foreach ( $conds as $type => $cond ) {
147 $statValue = self::getStatValue( $stats, $type );
148 $max = $stats[MessageGroupStats::TOTAL];
149 $match = $match && self::matchCondition( $statValue, $cond, $max );