Merge "SpecialStatistics::getOtherStats use standard language instead of inContentLan...
[lhc/web/wiklou.git] / maintenance / nextJobDB.php
index cf90cf6..ca550ae 100644 (file)
@@ -37,15 +37,15 @@ class nextJobDB extends Maintenance {
        }
 
        public function execute() {
-               global $wgMemc;
+               global $wgJobTypesExcludedFromDefaultQueue;
 
-               $type = false; // job type required/picked
+               // job type required/picked
                if ( $this->hasOption( 'types' ) ) {
                        $types = explode( ' ', $this->getOption( 'types' ) );
                } elseif ( $this->hasOption( 'type' ) ) {
                        $types = array( $this->getOption( 'type' ) );
                } else {
-                       $types = JobQueueGroup::singleton()->getDefaultQueueTypes();
+                       $types = false;
                }
 
                // Handle any required periodic queue maintenance
@@ -64,7 +64,10 @@ class nextJobDB extends Maintenance {
                        // Flatten the tree of candidates into a flat list so that a random
                        // item can be selected, weighing each queue (type/db tuple) equally.
                        foreach ( $pendingDBs as $type => $dbs ) {
-                               if ( in_array( $type, $types ) ) {
+                               if (
+                                       ( is_array( $types ) && in_array( $type, $types ) ) ||
+                                       ( $types === false && !in_array( $type, $wgJobTypesExcludedFromDefaultQueue ) )
+                               ) {
                                        foreach ( $dbs as $db ) {
                                                $candidates[] = array( $type, $db );
                                        }
@@ -74,10 +77,9 @@ class nextJobDB extends Maintenance {
                                return; // no jobs for this type
                        }
 
-                       list( $type, $db ) = $candidates[ mt_rand( 0, count( $candidates ) - 1 ) ];
-                       if ( !$this->checkJob( $type, $db ) ) { // queue is actually empty?
-                               $pendingDBs[$type] = array_diff( $pendingDBs[$type], $db );
-                               JobQueueAggregator::singleton()->notifyQueueEmpty( $db, $type );
+                       list( $type, $db ) = $candidates[mt_rand( 0, count( $candidates ) - 1 )];
+                       if ( JobQueueGroup::singleton( $db )->isQueueDeprioritized( $type ) ) {
+                               $pendingDBs[$type] = array_diff( $pendingDBs[$type], array( $db ) );
                                $again = true;
                        }
                } while ( $again );
@@ -89,17 +91,6 @@ class nextJobDB extends Maintenance {
                }
        }
 
-       /**
-        * Check if the specified database has a job of the specified type in it.
-        * The type may be false to indicate "all".
-        * @param $type string
-        * @param $dbName string
-        * @return bool
-        */
-       private function checkJob( $type, $dbName ) {
-               return !JobQueueGroup::singleton( $dbName )->get( $type )->isEmpty();
-       }
-
        /**
         * Do all ready periodic jobs for all databases every 5 minutes (and .1% of the time)
         * @return integer
@@ -125,4 +116,4 @@ class nextJobDB extends Maintenance {
 }
 
 $maintClass = "nextJobDb";
-require_once( RUN_MAINTENANCE_IF_MAIN );
+require_once RUN_MAINTENANCE_IF_MAIN;