diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2007-09-14 13:18:58 +0200 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2007-09-14 13:18:58 +0200 |
commit | 8f416baead93a48e5799e44b8bd2e2c4859f4e04 (patch) | |
tree | cd47ac55eb80a39e3225e8b4f3161b88ea16c2cf /maintenance/archives/populateSha1.php | |
parent | d7d08bd1a17618c7d77a6b9b2989e9f7293d6ed6 (diff) |
auf Version 1.11 aktualisiert; Login-Bug behoben
Diffstat (limited to 'maintenance/archives/populateSha1.php')
-rw-r--r-- | maintenance/archives/populateSha1.php | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/maintenance/archives/populateSha1.php b/maintenance/archives/populateSha1.php new file mode 100644 index 00000000..a34d36d3 --- /dev/null +++ b/maintenance/archives/populateSha1.php @@ -0,0 +1,43 @@ +<?php + +# Optional upgrade script to populate the img_sha1 field + +$optionsWithArgs = array( 'method' ); +require_once( dirname(__FILE__).'/../commandLine.inc' ); +$method = isset( $args['method'] ) ? $args['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 ) . ' -p' . wfEscapeShellArg( $wgDBpassword, $wgDBname ); +if ( $method == 'pipe' ) { + $pipe = popen( $cmd, 'w' ); + fwrite( $pipe, "-- hello\n" ); +} + +foreach ( $res as $row ) { + $file = wfLocalFile( $row->img_name ); + $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 ); + } else { + $dbw->query( $sql, $fname ); + } + } +} +if ( $method == 'pipe' ) { + fflush( $pipe ); + pclose( $pipe ); +} +$t += microtime( true ); +print "Done in $t seconds\n"; + +?> |