r50515 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r50514‎ | r50515 | r50516 >
Date:13:43, 12 May 2009
Author:tstarling
Status:ok (Comments)
Tags:
Comment:
Quick hack to allow creation of blobs tables with names other than "blobs"
Modified paths:
  • /trunk/phase3/maintenance/addwiki.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/addwiki.php
@@ -63,7 +63,6 @@
6464 }
6565 if ( count( $stores ) ) {
6666 require_once( 'ExternalStoreDB.php' );
67 - print "Initialising external storage $store...\n";
6867 global $wgDBuser, $wgDBpassword, $wgExternalServers;
6968 foreach ( $stores as $storeURL ) {
7069 $m = array();
@@ -72,17 +71,23 @@
7372 }
7473
7574 $cluster = $m[1];
 75+ print "Initialising external storage $cluster...\n";
7676
7777 # Hack
7878 $wgExternalServers[$cluster][0]['user'] = $wgDBuser;
7979 $wgExternalServers[$cluster][0]['password'] = $wgDBpassword;
80 -
 80+
8181 $store = new ExternalStoreDB;
82 - $extdb =& $store->getMaster( $cluster );
 82+ $extdb = $store->getMaster( $cluster );
8383 $extdb->query( "SET table_type=InnoDB" );
8484 $extdb->query( "CREATE DATABASE $dbName" );
8585 $extdb->selectDB( $dbName );
86 - dbsource( "$maintenance/storage/blobs.sql", $extdb );
 86+
 87+ # Hack x2
 88+ $blobsTable = $store->getTable( $extdb );
 89+ $blobsFile = popen( "sed s/blobs\\\\\\>/$blobsTable/ $maintenance/storage/blobs.sql", 'r' );
 90+ $extdb->sourceStream( $blobsFile );
 91+ pclose( $blobsFile );
8792 $extdb->immediateCommit();
8893 }
8994 }

Comments

#Comment by Brion VIBBER (talk | contribs)   20:55, 14 May 2009

I'm going to assume that sed command line has the right number of backslashes, cuz it makes my brain hurt.

Long term we should either take addwiki.php out of core or we should generalize it of course. :)

#Comment by Tim Starling (talk | contribs)   01:02, 15 May 2009

One for the sed regex, doubled for the shell. Another to escape the > from the shell, makes three. Doubled for PHP double quotes, makes 6 backslashes. Tested pre-commit.

Really Database::replaceVars() or tableName() should be able to do this, we just need a way to pass the blobs table name or cluster name down from the caller.

Status & tagging log