Fixed nextJobDB.php to handle recent job queue changes.
authorAaron Schulz <aschulz@wikimedia.org>
Wed, 31 Oct 2012 22:24:52 +0000 (15:24 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Wed, 31 Oct 2012 22:24:57 +0000 (15:24 -0700)
Change-Id: I98533ed599d27bbfc9043e906a758e3bc8903de0

maintenance/nextJobDB.php

index e66e981..75018de 100644 (file)
@@ -97,17 +97,23 @@ class nextJobDB extends Maintenance {
         * @return bool
         */
        function checkJob( $type, $dbName ) {
-               $lb = wfGetLB( $dbName );
-               $db = $lb->getConnection( DB_MASTER, array(), $dbName );
+               global $wgJobTypesExcludedFromDefaultQueue;
+
                if ( $type === false ) {
-                       $conds = Job::defaultQueueConditions( );
+                       $lb = wfGetLB( $dbName );
+                       $db = $lb->getConnection( DB_MASTER, array(), $dbName );
+                       $conds = array();
+                       if ( count( $wgJobTypesExcludedFromDefaultQueue ) > 0 ) {
+                               foreach ( $wgJobTypesExcludedFromDefaultQueue as $cmdType ) {
+                                       $conds[] = "job_cmd != " . $db->addQuotes( $cmdType );
+                               }
+                       }
+                       $exists = (bool)$db->selectField( 'job', '1', $conds, __METHOD__ );
+                       $lb->reuseConnection( $db );
                } else {
-                       $conds = array( 'job_cmd' => $type );
+                       $exists = !JobQueueGroup::singleton( $dbName )->get( $type )->isEmpty();
                }
 
-
-               $exists = (bool) $db->selectField( 'job', '1', $conds, __METHOD__ );
-               $lb->reuseConnection( $db );
                return $exists;
        }