Don't require commandLine.inc when not using the command line; instead, move wfWaitFo...
authorAryeh Gregor <simetrical@users.mediawiki.org>
Tue, 18 Mar 2008 13:18:06 +0000 (13:18 +0000)
committerAryeh Gregor <simetrical@users.mediawiki.org>
Tue, 18 Mar 2008 13:18:06 +0000 (13:18 +0000)
includes/GlobalFunctions.php
maintenance/commandLine.inc
maintenance/populateCategory.inc

index 71b135f..7acd3e8 100644 (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();
+               }
+       }
+}
index f7bb53f..0bdfe13 100644 (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();
-               }
-       }
-}
-
-
-
-?>
index 497f4b5..f17e5e8 100644 (file)
@@ -4,8 +4,6 @@
  * @author Simetrical
  */
 
-require_once "commandLine.inc";
-
 define( 'REPORTING_INTERVAL', 1000 );
 
 function populateCategory( $begin, $maxlag, $throttle, $force ) {