Some HipHop fixes:
[lhc/web/wiklou.git] / maintenance / populateSha1.php
index cc06a2a..1ab9109 100644 (file)
@@ -20,7 +20,7 @@
  * @ingroup Maintenance
  */
 
-require_once( dirname(__FILE__).'/Maintenance.php' );
+require_once( dirname( __FILE__ ) . '/Maintenance.php' );
 
 class PopulateSha1 extends Maintenance {
        public function __construct() {
@@ -37,14 +37,14 @@ class PopulateSha1 extends Maintenance {
 
                $t = -microtime( true );
                $dbw = wfGetDB( DB_MASTER );
-               if( $file ) {
-                       $res = $dbw->selectRow( 
-                               'image', 
-                               array( 'img_name' ), 
+               if ( $file ) {
+                       $res = $dbw->selectRow(
+                               'image',
+                               array( 'img_name' ),
                                array( 'img_name' => $dbw->addQuotes( $file ) ),
                                __METHOD__
                        );
-                       if( !$res ) {
+                       if ( !$res ) {
                                $this->error( "No such file: $file", true );
                                return;
                        }
@@ -52,23 +52,23 @@ class PopulateSha1 extends Maintenance {
                        $res = $dbw->select( 'image', array( 'img_name' ), array( 'img_sha1' => '' ), __METHOD__ );
                }
                $imageTable = $dbw->tableName( 'image' );
-               $oldimageTable = $dbw->tableName( 'oldimage' );
-               $batch = array();
-       
-               $cmd = 'mysql -u' . wfEscapeShellArg( $wgDBuser ) . 
-                       ' -h' . wfEscapeShellArg( $wgDBserver ) .
-                       ' -p' . wfEscapeShellArg( $wgDBpassword, $wgDBname );
+
                if ( $method == 'pipe' ) {
+                       // @todo FIXME: Kill this and replace with a second unbuffered DB connection.
+                       global $wgDBuser, $wgDBserver, $wgDBpassword, $wgDBname;
+                       $cmd = 'mysql -u' . wfEscapeShellArg( $wgDBuser ) .
+                               ' -h' . wfEscapeShellArg( $wgDBserver ) .
+                               ' -p' . wfEscapeShellArg( $wgDBpassword, $wgDBname );
                        $this->output( "Using pipe method\n" );
                        $pipe = popen( $cmd, 'w' );
                }
-       
+
                $numRows = $res->numRows();
                $i = 0;
                foreach ( $res as $row ) {
                        if ( $i % 100 == 0 ) {
                                $this->output( sprintf( "Done %d of %d, %5.3f%%  \r", $i, $numRows, $i / $numRows * 100 ) );
-                               wfWaitForSlaves( 5 );
+                               wfWaitForSlaves();
                        }
                        $file = wfLocalFile( $row->img_name );
                        if ( !$file ) {
@@ -96,4 +96,4 @@ class PopulateSha1 extends Maintenance {
 }
 
 $maintClass = "PopulateSha1";
-require_once( DO_MAINTENANCE );
+require_once( RUN_MAINTENANCE_IF_MAIN );