Doxygen documentation update: * Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group. * Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file. * Removed some empty comments * Removed some ?> Added following groups: * ExternalStorage * JobQueue * MaintenanceLanguage One more thing: there are still a lot of warnings when generating the doc.
60 lines
1.4 KiB
PHP
60 lines
1.4 KiB
PHP
<?php
|
|
/**
|
|
* Pick a database that has pending jobs
|
|
*
|
|
* @file
|
|
* @ingroup Maintenance
|
|
*/
|
|
|
|
$options = array( 'type' );
|
|
|
|
require_once( 'commandLine.inc' );
|
|
|
|
$type = isset($options['type'])
|
|
? $options['type']
|
|
: false;
|
|
|
|
$mckey = $type === false
|
|
? "jobqueue:dbs"
|
|
: "jobqueue:dbs:$type";
|
|
|
|
$pendingDBs = $wgMemc->get( $mckey );
|
|
if ( !$pendingDBs ) {
|
|
$pendingDBs = array();
|
|
# Cross-reference DBs by master DB server
|
|
$dbsByMaster = array();
|
|
foreach ( $wgLocalDatabases as $db ) {
|
|
$lb = wfGetLB( $db );
|
|
$dbsByMaster[$lb->getServerName(0)][] = $db;
|
|
}
|
|
|
|
foreach ( $dbsByMaster as $master => $dbs ) {
|
|
$dbConn = wfGetDB( DB_MASTER, array(), $dbs[0] );
|
|
$stype = $dbConn->addQuotes($type);
|
|
|
|
# Padding row for MySQL bug
|
|
$sql = "(SELECT '-------------------------------------------')";
|
|
foreach ( $dbs as $dbName ) {
|
|
if ( $sql != '' ) {
|
|
$sql .= ' UNION ';
|
|
}
|
|
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
|
|
while ( $row = $dbConn->fetchRow( $res ) ) {
|
|
$pendingDBs[] = $row[0];
|
|
}
|
|
}
|
|
|
|
$wgMemc->set( $mckey, $pendingDBs, 300 );
|
|
}
|
|
|
|
if ( $pendingDBs ) {
|
|
echo $pendingDBs[mt_rand(0, count( $pendingDBs ) - 1)];
|
|
}
|
|
|
|
|