Index: trunk/phase3/maintenance/nextJobDB.php |
— | — | @@ -65,25 +65,31 @@ |
66 | 66 | foreach ( $dbsByMaster as $master => $dbs ) { |
67 | 67 | $dbConn = wfGetDB( DB_MASTER, array(), $dbs[0] ); |
68 | 68 | $stype = $dbConn->addQuotes($type); |
69 | | - $jobTable = $dbConn->getTable( 'job' ); |
| 69 | + $jobTable = $dbConn->tableName( 'job' ); |
70 | 70 | |
71 | 71 | # Padding row for MySQL bug |
72 | | - $sql = "(SELECT '-------------------------------------------')"; |
| 72 | + $sql = "(SELECT '-------------------------------------------' as db)"; |
73 | 73 | foreach ( $dbs as $dbName ) { |
74 | 74 | if ( $sql != '' ) { |
75 | 75 | $sql .= ' UNION '; |
76 | 76 | } |
77 | 77 | if ($type === false) |
78 | | - $sql .= "(SELECT '$dbName' FROM `$dbName`.$jobTable LIMIT 1)"; |
| 78 | + $sql .= "(SELECT '$dbName' as db FROM `$dbName`.$jobTable LIMIT 1)"; |
79 | 79 | else |
80 | | - $sql .= "(SELECT '$dbName' FROM `$dbName`.$jobTable WHERE job_cmd=$stype LIMIT 1)"; |
| 80 | + $sql .= "(SELECT '$dbName' as db FROM `$dbName`.$jobTable WHERE job_cmd=$stype LIMIT 1)"; |
81 | 81 | } |
82 | 82 | $res = $dbConn->query( $sql, __METHOD__ ); |
83 | | - $row = $dbConn->fetchRow( $res ); // discard padding row |
84 | | - while ( $row = $dbConn->fetchRow( $res ) ) { |
85 | | - $pendingDBs[] = $row[0]; |
| 83 | + $first = true; |
| 84 | + foreach ( $res as $row ) { |
| 85 | + if ( $first ) { |
| 86 | + // discard padding row |
| 87 | + $first = false; |
| 88 | + continue; |
| 89 | + } |
| 90 | + $pendingDBs[] = $row->db; |
86 | 91 | } |
87 | 92 | } |
| 93 | + return $pendingDBs; |
88 | 94 | } |
89 | 95 | } |
90 | 96 | |