diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2007-05-16 20:58:53 +0000 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2007-05-16 20:58:53 +0000 |
commit | cecb985bee3bdd252e1b8dc0bd500b37cd52be01 (patch) | |
tree | 17266aa237742640aabee7856f0202317a45d540 /maintenance/nextJobDB.php | |
parent | 0bac06c301f2a83edb0236e4c2434da16848d549 (diff) |
Aktualisierung auf MediaWiki 1.10.0
Plugins angepasst und verbessert
kleine Korrekturen am Design
Diffstat (limited to 'maintenance/nextJobDB.php')
-rw-r--r-- | maintenance/nextJobDB.php | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/maintenance/nextJobDB.php b/maintenance/nextJobDB.php new file mode 100644 index 00000000..7aa05a27 --- /dev/null +++ b/maintenance/nextJobDB.php @@ -0,0 +1,48 @@ +<?php + +/* + * Pick a database that has pending jobs + */ + +require_once( 'commandLine.inc' ); + +$pendingDBs = $wgMemc->get( 'jobqueue:dbs' ); +if ( !$pendingDBs ) { + $pendingDBs = array(); + # Cross-reference DBs by master DB server + $dbsByMaster = array(); + $defaultMaster = $wgAlternateMaster['DEFAULT']; + foreach ( $wgLocalDatabases as $db ) { + if ( isset( $wgAlternateMaster[$db] ) ) { + $dbsByMaster[$wgAlternateMaster[$db]][] = $db; + } else { + $dbsByMaster[$defaultMaster][] = $db; + } + } + + foreach ( $dbsByMaster as $master => $dbs ) { + $dbConn = new Database( $master, $wgDBuser, $wgDBpassword ); + + # Padding row for MySQL bug + $sql = "(SELECT '-------------------------------------------')"; + foreach ( $dbs as $dbName ) { + if ( $sql != '' ) { + $sql .= ' UNION '; + } + $sql .= "(SELECT '$dbName' FROM `$dbName`.job LIMIT 1)"; + } + $res = $dbConn->query( $sql, 'nextJobDB.php' ); + $row = $dbConn->fetchRow( $res ); // discard padding row + while ( $row = $dbConn->fetchRow( $res ) ) { + $pendingDBs[] = $row[0]; + } + } + + $wgMemc->set( 'jobqueue:dbs', $pendingDBs, 300 ); +} + +if ( $pendingDBs ) { + echo $pendingDBs[mt_rand(0, count( $pendingDBs ) - 1)]; +} + +?> |