* @ingroup Maintenance
*/
-require_once( dirname(__FILE__).'/Maintenance.php' );
+require_once( dirname( __FILE__ ) . '/Maintenance.php' );
class PopulateSha1 extends Maintenance {
public function __construct() {
$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;
}
$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 ) {
}
$maintClass = "PopulateSha1";
-require_once( DO_MAINTENANCE );
+require_once( RUN_MAINTENANCE_IF_MAIN );