Index: trunk/phase3/maintenance/renameDbPrefix.php |
— | — | @@ -1,17 +1,17 @@ |
2 | 2 | <?php |
3 | 3 | /** |
4 | | - * Run this script to after changing $wgDBPrefix on a wiki. |
| 4 | + * Run this script to after changing $wgDBprefix on a wiki. |
5 | 5 | * The wiki will have to get downtime to do this correctly. |
6 | 6 | * |
7 | 7 | * @file |
8 | 8 | * @ingroup Maintenance |
9 | 9 | */ |
10 | | -$optionsWithArgs = array('old','new','help'); |
| 10 | +$optionsWithArgs = array( 'old', 'new', 'help' ); |
11 | 11 | |
12 | 12 | require_once( 'commandLine.inc' ); |
13 | 13 | |
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"; |
16 | 16 | print " --help : this help message\n"; |
17 | 17 | print " --old x : old db prefix x\n"; |
18 | 18 | print " --old 0 : EMPTY old db prefix x\n"; |
— | — | @@ -26,7 +26,7 @@ |
27 | 27 | } else { |
28 | 28 | // Use nice safe, sane, prefixes |
29 | 29 | preg_match( '/^[a-zA-Z]+_$/', $options['old'], $m ); |
30 | | - $old = isset($m[0]) ? $m[0] : false; |
| 30 | + $old = isset( $m[0] ) ? $m[0] : false; |
31 | 31 | } |
32 | 32 | // Allow for no new prefix |
33 | 33 | if( $options['new'] === '0' ) { |
— | — | @@ -34,10 +34,10 @@ |
35 | 35 | } else { |
36 | 36 | // Use nice safe, sane, prefixes |
37 | 37 | preg_match( '/^[a-zA-Z]+_$/', $options['new'], $m ); |
38 | | - $new = isset($m[0]) ? $m[0] : false; |
| 38 | + $new = isset( $m[0] ) ? $m[0] : false; |
39 | 39 | } |
40 | 40 | |
41 | | -if( $old===false || $new===false ) { |
| 41 | +if( $old === false || $new === false ) { |
42 | 42 | print "Invalid prefix!\n"; |
43 | 43 | wfDie(); |
44 | 44 | } |
— | — | @@ -50,7 +50,7 @@ |
51 | 51 | $count = 0; |
52 | 52 | |
53 | 53 | $dbw = wfGetDB( DB_MASTER ); |
54 | | -$res = $dbw->query( "SHOW TABLES LIKE '".$dbw->escapeLike($old)."%'" ); |
| 54 | +$res = $dbw->query( "SHOW TABLES LIKE '".$dbw->escapeLike( $old )."%'" ); |
55 | 55 | foreach( $res as $row ) { |
56 | 56 | // XXX: odd syntax. MySQL outputs an oddly cased "Tables of X" |
57 | 57 | // sort of message. Best not to try $row->x stuff... |
— | — | @@ -58,11 +58,10 @@ |
59 | 59 | // Silly for loop over one field... |
60 | 60 | foreach( $fields as $resName => $table ) { |
61 | 61 | // $old should be regexp safe ([a-zA-Z_]) |
62 | | - $newTable = preg_replace( '/^'.$old.'/',$new,$table); |
| 62 | + $newTable = preg_replace( '/^'.$old.'/', $new, $table ); |
63 | 63 | print "Renaming table $table to $newTable\n"; |
64 | 64 | $dbw->query( "RENAME TABLE $table TO $newTable" ); |
65 | 65 | } |
66 | 66 | $count++; |
67 | 67 | } |
68 | | -print "Done! [$count tables]\n"; |
69 | | - |
| 68 | +print "Done! [$count tables]\n"; |
\ No newline at end of file |