* Drop 5.1 compat code
[lhc/web/wiklou.git] / maintenance / addwiki.php
index 8e7cbfc..bed2ad6 100644 (file)
@@ -31,12 +31,16 @@ require_once( dirname( __FILE__ ) . '/Maintenance.php' );
 
 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() {
@@ -44,9 +48,8 @@ class AddWiki extends Maintenance {
        }
 
        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 );
@@ -90,7 +93,7 @@ class AddWiki extends Maintenance {
                # Initialise external storage
                if ( is_array( $wgDefaultExternalStore ) ) {
                        $stores = $wgDefaultExternalStore;
-               } elseif ( $stores ) {
+               } elseif ( $wgDefaultExternalStore ) {
                        $stores = array( $wgDefaultExternalStore );
                } else {
                        $stores = array();
@@ -126,14 +129,12 @@ class AddWiki extends Maintenance {
                        }
                }
 
-               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" );
 
@@ -148,24 +149,24 @@ class AddWiki extends Maintenance {
                # 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==
@@ -466,4 +467,4 @@ EOT;
 }
 
 $maintClass = "AddWiki";
-require_once( DO_MAINTENANCE );
+require_once( RUN_MAINTENANCE_IF_MAIN );