Don't require commandLine.inc when not using the command line; instead, move wfWaitForSlaves() to GlobalFunctions.php, which is where I expected it to be to begin with. That appears, sensibly, to be loaded by all code paths. While I'm there, add some documentation.

This commit is contained in:
Aryeh Gregor 2008-03-18 13:18:06 +00:00
parent f34672bc87
commit fa7fd87647
3 changed files with 30 additions and 26 deletions

View file

@ -2437,7 +2437,37 @@ function wfMaxlagError( $host, $lag, $maxLag ) {
/**
* Throws an E_USER_NOTICE saying that $function is deprecated
* @param string $function
* @return null
*/
function wfDeprecated( $function ) {
trigger_error( "Use of $function is deprecated", E_USER_NOTICE );
}
/**
* Sleep until the worst slave's replication lag is less than or equal to
* $maxLag, in seconds. Use this when updating very large numbers of rows, as
* in maintenance scripts, to avoid causing too much lag. Of course, this is
* a no-op if there are no slaves.
*
* Every time the function has to wait for a slave, it will print a message to
* that effect (and then sleep for a little while), so it's probably not best
* to use this outside maintenance scripts in its present form.
*
* @param int $maxLag
* @return null
*/
function wfWaitForSlaves( $maxLag ) {
global $wgLoadBalancer;
if( $maxLag ) {
list( $host, $lag ) = $wgLoadBalancer->getMaxLag();
while( $lag > $maxLag ) {
$name = @gethostbyaddr( $host );
if( $name !== false ) {
$host = $name;
}
print "Waiting for $host (lagged $lag seconds)...\n";
sleep($maxLag);
list( $host, $lag ) = $wgLoadBalancer->getMaxLag();
}
}
}

View file

@ -236,27 +236,3 @@ require_once( "$IP/includes/Setup.php" );
require_once( "$IP/install-utils.inc" );
$wgTitle = null; # Much much faster startup than creating a title object
set_time_limit(0);
// --------------------------------------------------------------------
// Functions
// --------------------------------------------------------------------
function wfWaitForSlaves( $maxLag ) {
global $wgLoadBalancer;
if ( $maxLag ) {
list( $host, $lag ) = $wgLoadBalancer->getMaxLag();
while ( $lag > $maxLag ) {
$name = @gethostbyaddr( $host );
if ( $name !== false ) {
$host = $name;
}
print "Waiting for $host (lagged $lag seconds)...\n";
sleep($maxLag);
list( $host, $lag ) = $wgLoadBalancer->getMaxLag();
}
}
}
?>

View file

@ -4,8 +4,6 @@
* @author Simetrical
*/
require_once "commandLine.inc";
define( 'REPORTING_INTERVAL', 1000 );
function populateCategory( $begin, $maxlag, $throttle, $force ) {