r48998 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r48997‎ | r48998 | r48999 >
Date:12:27, 29 March 2009
Author:ashley
Status:ok
Tags:
Comment:
renameDbPrefix.php tweaks: corrected script name in help message (this is not updateSpecialPages.php ;) + added spacing
Modified paths:
  • /trunk/phase3/maintenance/renameDbPrefix.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/renameDbPrefix.php
@@ -1,17 +1,17 @@
22 <?php
33 /**
4 - * Run this script to after changing $wgDBPrefix on a wiki.
 4+ * Run this script to after changing $wgDBprefix on a wiki.
55 * The wiki will have to get downtime to do this correctly.
66 *
77 * @file
88 * @ingroup Maintenance
99 */
10 -$optionsWithArgs = array('old','new','help');
 10+$optionsWithArgs = array( 'old', 'new', 'help' );
1111
1212 require_once( 'commandLine.inc' );
1313
14 -if( @$options['help'] || !isset($options['old']) || !isset($options['new']) ) {
15 - print "usage:updateSpecialPages.php [--help] [--old x] [new y]\n";
 14+if( @$options['help'] || !isset( $options['old'] ) || !isset( $options['new'] ) ) {
 15+ print "usage: renameDbPrefix.php [--help] [--old x] [new y]\n";
1616 print " --help : this help message\n";
1717 print " --old x : old db prefix x\n";
1818 print " --old 0 : EMPTY old db prefix x\n";
@@ -26,7 +26,7 @@
2727 } else {
2828 // Use nice safe, sane, prefixes
2929 preg_match( '/^[a-zA-Z]+_$/', $options['old'], $m );
30 - $old = isset($m[0]) ? $m[0] : false;
 30+ $old = isset( $m[0] ) ? $m[0] : false;
3131 }
3232 // Allow for no new prefix
3333 if( $options['new'] === '0' ) {
@@ -34,10 +34,10 @@
3535 } else {
3636 // Use nice safe, sane, prefixes
3737 preg_match( '/^[a-zA-Z]+_$/', $options['new'], $m );
38 - $new = isset($m[0]) ? $m[0] : false;
 38+ $new = isset( $m[0] ) ? $m[0] : false;
3939 }
4040
41 -if( $old===false || $new===false ) {
 41+if( $old === false || $new === false ) {
4242 print "Invalid prefix!\n";
4343 wfDie();
4444 }
@@ -50,7 +50,7 @@
5151 $count = 0;
5252
5353 $dbw = wfGetDB( DB_MASTER );
54 -$res = $dbw->query( "SHOW TABLES LIKE '".$dbw->escapeLike($old)."%'" );
 54+$res = $dbw->query( "SHOW TABLES LIKE '".$dbw->escapeLike( $old )."%'" );
5555 foreach( $res as $row ) {
5656 // XXX: odd syntax. MySQL outputs an oddly cased "Tables of X"
5757 // sort of message. Best not to try $row->x stuff...
@@ -58,11 +58,10 @@
5959 // Silly for loop over one field...
6060 foreach( $fields as $resName => $table ) {
6161 // $old should be regexp safe ([a-zA-Z_])
62 - $newTable = preg_replace( '/^'.$old.'/',$new,$table);
 62+ $newTable = preg_replace( '/^'.$old.'/', $new, $table );
6363 print "Renaming table $table to $newTable\n";
6464 $dbw->query( "RENAME TABLE $table TO $newTable" );
6565 }
6666 $count++;
6767 }
68 -print "Done! [$count tables]\n";
69 -
 68+print "Done! [$count tables]\n";
\ No newline at end of file

Status & tagging log