<?php
-$wgNoDBParam = true;
-
+$wgNoDBParam = true;
+
require_once( "commandLine.inc" );
require_once( "rebuildInterwiki.inc" );
require_once( "languages/Names.php" );
if ( count( $args ) != 3 ) {
- die( "Usage: php addwiki.php <language> <site> <dbname>\n" );
+ wfDie( "Usage: php addwiki.php <language> <site> <dbname>\n" );
}
-addWiki( $args[0], $args[1], $args[2] );
+addWiki( $args[0], $args[1], $args[2] );
# -----------------------------------------------------------------
function addWiki( $lang, $site, $dbName )
{
- global $IP, $wgLanguageNames;
+ global $IP, $wgLanguageNames, $wgDefaultExternalStore;
$name = $wgLanguageNames[$lang];
$maintenance = "$IP/maintenance";
print "Creating database $dbName for $lang.$site\n";
+
# Set up the database
$dbw->query( "SET table_type=Innodb" );
$dbw->query( "CREATE DATABASE $dbName" );
$dbw->selectDB( $dbName );
-
+
print "Initialising tables\n";
dbsource( "$maintenance/tables.sql", $dbw );
dbsource( "$IP/extensions/OAI/update_table.sql", $dbw );
$dbw->query( "INSERT INTO site_stats(ss_row_id) VALUES (1)" );
+ # Initialise external storage
+ if ( $wgDefaultExternalStore && preg_match( '!^DB://(.*)$!', $wgDefaultExternalStore, $m ) ) {
+ print "Initialising external storage...\n";
+ require_once( 'ExternalStoreDB.php' );
+ global $wgDBuser, $wgDBpassword, $wgExternalServers;
+ $cluster = $m[1];
+
+ # Hack
+ $wgExternalServers[$cluster][0]['user'] = $wgDBuser;
+ $wgExternalServers[$cluster][0]['password'] = $wgDBpassword;
+
+ $store = new ExternalStoreDB;
+ $extdb =& $store->getMaster( $cluster );
+ $extdb->query( "SET table_type=InnoDB" );
+ $extdb->query( "CREATE DATABASE $dbName" );
+ $extdb->selectDB( $dbName );
+ dbsource( "$maintenance/storage/blobs.sql", $extdb );
+ $extdb->immediateCommit();
+ }
+
$wgTitle = Title::newMainPage();
$wgArticle = new Article( $wgTitle );
$ucsite = ucfirst( $site );
==Sister projects==
[http://meta.wikipedia.org Meta-Wikipedia] | [http://www.wiktionary.org Wikitonary] | [http://www.wikibooks.org Wikibooks] | [http://www.wikinews.org Wikinews] | [http://www.wikiquote.org Wikiquote] | [http://www.wikisource.org Wikisource]
-See the [http://www.wikipedia.org Wikipedia portal] for other language Wikipedias.
+See the [http://www.wikipedia.org Wikipedia portal] for other language Wikipedias.
[[aa:]]
[[af:]]
[[zh:]]
[[zu:]]
", '', false, false );
-
+
print "Adding to dblists\n";
# Add to dblist
$file = fopen( "$common/all.dblist", "a" );
fwrite( $file, "$dbName\n" );
fclose( $file );
-
+
# Update the sublists
system("cd $common && ./refresh-dblist");
$tempname = tempnam( '/tmp', 'addwiki' );
$file = fopen( $tempname, 'w' );
if ( !$file ) {
- die( "Error, unable to open temporary file $tempname\n" );
+ wfDie( "Error, unable to open temporary file $tempname\n" );
}
fwrite( $file, $sql );
fclose( $file );
print "Script ended. You now want to run sync-common-all to publish *dblist files (check them for duplicates first)\n";
}
+?>