Index: trunk/tools/mwmultiversion/multiversion/switchAllMediaWikis |
— | — | @@ -40,24 +40,15 @@ |
41 | 41 | die( "Unable to read wikiversions.dat.\n" ); |
42 | 42 | } |
43 | 43 | |
44 | | - $datList = ""; |
| 44 | + $what = '/^(\w+) ' . preg_quote( $oldVersion ) . '( |$)/'; |
| 45 | + $with = '$1 ' . $newVersion . '$2'; |
| 46 | + |
45 | 47 | $count = 0; |
| 48 | + $datList = ""; |
46 | 49 | foreach ( $verList as $row ) { |
47 | | - $items = explode( ' ', trim( $row ) ); |
48 | | - # Existing values... |
49 | | - $dbName = $items[0]; |
50 | | - $version = $items[1]; |
51 | | - $extVersion = isset( $items[2] ) ? $items[2] : ''; |
52 | | - # Update this wiki? |
53 | | - if ( $version === $oldVersion || $oldVersion === 'all' ) { |
54 | | - $version = $newVersion; // switch! |
55 | | - $count++; |
56 | | - } |
57 | | - if ( $extVersion !== '' ) { |
58 | | - $datList .= "{$dbName} {$version} {$extVersion}\n"; |
59 | | - } else { |
60 | | - $datList .= "{$dbName} {$version}\n"; |
61 | | - } |
| 50 | + $n = 0; |
| 51 | + $datList .= preg_replace( $what, $with, trim( $row ), -1, $n ) . "\n"; |
| 52 | + $count += $n; |
62 | 53 | } |
63 | 54 | |
64 | 55 | # Backup old wikiversions.dat... |