nextJobDB should have a way to pick a db having specific type of job in the queue
authorRiver Tarnell <river@users.mediawiki.org>
Fri, 11 May 2007 07:44:40 +0000 (07:44 +0000)
committerRiver Tarnell <river@users.mediawiki.org>
Fri, 11 May 2007 07:44:40 +0000 (07:44 +0000)
maintenance/nextJobDB.php

index 7aa05a2..3073227 100644 (file)
@@ -4,8 +4,14 @@
  * Pick a database that has pending jobs
  */
 
+$options = array( 'type'  );
+
 require_once( 'commandLine.inc' );
 
+$type = isset($options['type'])
+               ? $options['type']
+               : false;
+
 $pendingDBs = $wgMemc->get( 'jobqueue:dbs' );
 if ( !$pendingDBs ) {
        $pendingDBs = array();
@@ -22,6 +28,7 @@ if ( !$pendingDBs ) {
 
        foreach ( $dbsByMaster as $master => $dbs ) {
                $dbConn = new Database( $master, $wgDBuser, $wgDBpassword );
+               $stype = $dbConn->addQuotes($type);
 
                # Padding row for MySQL bug
                $sql = "(SELECT '-------------------------------------------')";
@@ -29,7 +36,10 @@ if ( !$pendingDBs ) {
                        if ( $sql != '' ) {
                                $sql .= ' UNION ';
                        }
-                       $sql .= "(SELECT '$dbName' FROM `$dbName`.job LIMIT 1)";
+                       if ($type === false)
+                               $sql .= "(SELECT '$dbName' FROM `$dbName`.job LIMIT 1)";
+                       else
+                               $sql .= "(SELECT '$dbName' FROM `$dbName`.job WHERE job_cmd='$stype' LIMIT 1)";
                }
                $res = $dbConn->query( $sql, 'nextJobDB.php' );
                $row = $dbConn->fetchRow( $res ); // discard padding row