r54639 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r54638‎ | r54639 | r54640 >
Date:19:35, 8 August 2009
Author:ialex
Status:ok
Tags:
Comment:
Make this script really work :)
* Fatal error: Call to undefined method DatabaseMysql::getTable()
* Fatal error: Cannot use object of type stdClass as array
* return $pendingDBs from nextJobDB::getPendingDbs()
Modified paths:
  • /trunk/phase3/maintenance/nextJobDB.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/nextJobDB.php
@@ -65,25 +65,31 @@
6666 foreach ( $dbsByMaster as $master => $dbs ) {
6767 $dbConn = wfGetDB( DB_MASTER, array(), $dbs[0] );
6868 $stype = $dbConn->addQuotes($type);
69 - $jobTable = $dbConn->getTable( 'job' );
 69+ $jobTable = $dbConn->tableName( 'job' );
7070
7171 # Padding row for MySQL bug
72 - $sql = "(SELECT '-------------------------------------------')";
 72+ $sql = "(SELECT '-------------------------------------------' as db)";
7373 foreach ( $dbs as $dbName ) {
7474 if ( $sql != '' ) {
7575 $sql .= ' UNION ';
7676 }
7777 if ($type === false)
78 - $sql .= "(SELECT '$dbName' FROM `$dbName`.$jobTable LIMIT 1)";
 78+ $sql .= "(SELECT '$dbName' as db FROM `$dbName`.$jobTable LIMIT 1)";
7979 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)";
8181 }
8282 $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;
8691 }
8792 }
 93+ return $pendingDBs;
8894 }
8995 }
9096

Status & tagging log