Bump $wgStyleVersion to 155.
[lhc/web/wiklou.git] / maintenance / renamewiki.php
1 <?php
2 /**
3 * Why yes, this *is* another special-purpose Wikimedia maintenance script!
4 * Should be fixed up and generalized.
5 *
6 * @file
7 * @ingroup Maintenance
8 */
9
10 require_once( "commandLine.inc" );
11
12 if ( count( $args ) != 2 ) {
13 wfDie( "Rename external storage dbs and leave a new one...\n" .
14 "Usage: php renamewiki.php <olddb> <newdb>\n" );
15 }
16
17 list( $from, $to ) = $args;
18
19 echo "Renaming blob tables in ES from $from to $to...\n";
20 echo "Sleeping 5 seconds...";
21 sleep(5);
22 echo "\n";
23
24 $maintenance = "$IP/maintenance";
25
26 # Initialise external storage
27 if ( is_array( $wgDefaultExternalStore ) ) {
28 $stores = $wgDefaultExternalStore;
29 } elseif ( $wgDefaultExternalStore ) {
30 $stores = array( $wgDefaultExternalStore );
31 } else {
32 $stores = array();
33 }
34 if ( count( $stores ) ) {
35 require_once( 'ExternalStoreDB.php' );
36 print "Initialising external storage $store...\n";
37 global $wgDBuser, $wgDBpassword, $wgExternalServers;
38 foreach ( $stores as $storeURL ) {
39 $m = array();
40 if ( !preg_match( '!^DB://(.*)$!', $storeURL, $m ) ) {
41 continue;
42 }
43
44 $cluster = $m[1];
45
46 # Hack
47 $wgExternalServers[$cluster][0]['user'] = $wgDBuser;
48 $wgExternalServers[$cluster][0]['password'] = $wgDBpassword;
49
50 $store = new ExternalStoreDB;
51 $extdb =& $store->getMaster( $cluster );
52 $extdb->query( "SET table_type=InnoDB" );
53 $extdb->query( "CREATE DATABASE {$to}" );
54 $extdb->query( "ALTER TABLE {$from}.blobs RENAME TO {$to}.blobs" );
55 $extdb->selectDB( $from );
56 dbsource( "$maintenance/storage/blobs.sql", $extdb );
57 $extdb->immediateCommit();
58 }
59 }
60
61 echo "done.\n";
62