Move populateSha1.php up from archives into maintenance root (nothing calls this...
authorChad Horohoe <demon@users.mediawiki.org>
Mon, 3 Aug 2009 22:05:03 +0000 (22:05 +0000)
committerChad Horohoe <demon@users.mediawiki.org>
Mon, 3 Aug 2009 22:05:03 +0000 (22:05 +0000)
maintenance/archives/populateSha1.php [deleted file]
maintenance/populateSha1.php [new file with mode: 0644]

diff --git a/maintenance/archives/populateSha1.php b/maintenance/archives/populateSha1.php
deleted file mode 100644 (file)
index 487d3ba..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-<?php
-/**
- * Optional upgrade script to populate the img_sha1 field
- *
- * @file
- * @ingroup MaintenanceArchive
- */
-
-$optionsWithArgs = array( 'method' );
-require_once( dirname(__FILE__).'/../commandLine.inc' );
-$method = isset( $options['method'] ) ? $options['method'] : 'normal';
-
-$t = -microtime( true );
-$fname = 'populateSha1.php';
-$dbw = wfGetDB( DB_MASTER );
-$res = $dbw->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 );
-
-?>
diff --git a/maintenance/populateSha1.php b/maintenance/populateSha1.php
new file mode 100644 (file)
index 0000000..6862ee8
--- /dev/null
@@ -0,0 +1,57 @@
+<?php
+/**
+ * Optional upgrade script to populate the img_sha1 field
+ *
+ * @file
+ * @ingroup MaintenanceArchive
+ */
+
+$optionsWithArgs = array( 'method' );
+require_once( dirname(__FILE__).'/commandLine.inc' );
+$method = isset( $options['method'] ) ? $options['method'] : 'normal';
+
+$t = -microtime( true );
+$fname = 'populateSha1.php';
+$dbw = wfGetDB( DB_MASTER );
+$res = $dbw->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 );