X-Git-Url: https://scripts.mit.edu/gitweb/autoinstallsdev/mediawiki.git/blobdiff_plain/8989532d3de45b196373107c7a812a68ac0ff2d9..d75ce11339b35963b5f8c3d53190819c1c025716:/maintenance/archives/populateSha1.php diff --git a/maintenance/archives/populateSha1.php b/maintenance/archives/populateSha1.php deleted file mode 100644 index 487d3bad..00000000 --- a/maintenance/archives/populateSha1.php +++ /dev/null @@ -1,59 +0,0 @@ -select( 'image', array( 'img_name' ), array( 'img_sha1' => '' ), $fname ); -$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' ) { - echo "Using pipe method\n"; - $pipe = popen( $cmd, 'w' ); -} - -$numRows = $res->numRows(); -$i = 0; -foreach ( $res as $row ) { - if ( $i % 100 == 0 ) { - printf( "Done %d of %d, %5.3f%% \r", $i, $numRows, $i / $numRows * 100 ); - wfWaitForSlaves( 5 ); - } - $file = wfLocalFile( $row->img_name ); - if ( !$file ) { - continue; - } - $sha1 = File::sha1Base36( $file->getPath() ); - if ( strval( $sha1 ) !== '' ) { - $sql = "UPDATE $imageTable SET img_sha1=" . $dbw->addQuotes( $sha1 ) . - " WHERE img_name=" . $dbw->addQuotes( $row->img_name ); - if ( $method == 'pipe' ) { - fwrite( $pipe, "$sql;\n" ); - } else { - $dbw->query( $sql, $fname ); - } - } - $i++; -} -if ( $method == 'pipe' ) { - fflush( $pipe ); - pclose( $pipe ); -} -$t += microtime( true ); -printf( "\nDone %d files in %.1f seconds\n", $numRows, $t ); - -?>