class AddWiki extends Maintenance {
public function __construct() {
+ global $wgNoDBParam;
+
parent::__construct();
$this->mDescription = "Add a new wiki to the family. Wikimedia specific!";
$this->addArg( 'language', 'Language code of new site, e.g. en' );
$this->addArg( 'site', 'Type of site, e.g. wikipedia' );
$this->addArg( 'dbname', 'Name of database to create, e.g. enwiki' );
$this->addArg( 'domain', 'Domain name of the wiki, e.g. en.wikipedia.org' );
+
+ $wgNoDBParam = true;
}
public function getDbType() {
}
public function execute() {
- global $IP, $wgDefaultExternalStore, $wgNoDBParam, $wgPasswordSender;
+ global $IP, $wgDefaultExternalStore;
- $wgNoDBParam = true;
$lang = $this->getArg( 0 );
$site = $this->getArg( 1 );
$dbName = $this->getArg( 2 );
# Initialise external storage
if ( is_array( $wgDefaultExternalStore ) ) {
$stores = $wgDefaultExternalStore;
- } elseif ( $stores ) {
+ } elseif ( $wgDefaultExternalStore ) {
$stores = array( $wgDefaultExternalStore );
} else {
$stores = array();
}
}
- global $wgTitle, $wgArticle;
- $wgTitle = Title::newFromText( wfMsgWeirdKey( "mainpage/$lang" ) );
- $this->output( "Writing main page to " . $wgTitle->getPrefixedDBkey() . "\n" );
- $wgArticle = new Article( $wgTitle );
+ $title = Title::newFromText( wfMessage( 'mainpage' )->inLanguage( $lang )->useDatabase( false )->plain() );
+ $this->output( "Writing main page to " . $title->getPrefixedDBkey() . "\n" );
+ $article = new Article( $title );
$ucsite = ucfirst( $site );
- $wgArticle->doEdit( $this->getFirstArticle( $ucsite, $name ), '', EDIT_NEW | EDIT_DEFER_UPDATES | EDIT_AUTOSUMMARY,
- false, null, false, false, '', true );
+ $article->doEdit( $this->getFirstArticle( $ucsite, $name ), '', EDIT_NEW | EDIT_AUTOSUMMARY );
$this->output( "Adding to dblists\n" );
# print "Constructing interwiki SQL\n";
# Rebuild interwiki tables
# passthru( '/home/wikipedia/conf/interwiki/update' );
-
+
$time = wfTimestamp( TS_RFC2822 );
// These arguments need to be escaped twice: once for echo and once for at
- $escDbName = wfEscapeShellArg( wfEscapeShellArg( $dbname ) );
+ $escDbName = wfEscapeShellArg( wfEscapeShellArg( $dbName ) );
$escTime = wfEscapeShellArg( wfEscapeShellArg( $time ) );
$escUcsite = wfEscapeShellArg( wfEscapeShellArg( $ucsite ) );
$escName = wfEscapeShellArg( wfEscapeShellArg( $name ) );
$escLang = wfEscapeShellArg( wfEscapeShellArg( $lang ) );
$escDomain = wfEscapeShellArg( wfEscapeShellArg( $domain ) );
shell_exec( "echo notifyNewProjects $escDbName $escTime $escUcsite $escName $escLang $escDomain | at now + 15 minutes" );
-
+
$this->output( "Script ended. You still have to:
* Add any required settings in InitialiseSettings.php
* Run sync-common-all
* Run /home/wikipedia/conf/interwiki/update
" );
}
-
+
private function getFirstArticle( $ucsite, $name ) {
return <<<EOT
==This subdomain is reserved for the creation of a [[wikimedia:Our projects|$ucsite]] in '''[[w:en:{$name}|{$name}]]''' language==
}
$maintClass = "AddWiki";
-require_once( DO_MAINTENANCE );
+require_once( RUN_MAINTENANCE_IF_MAIN );