Remove $wgTitle from all maintenance scripts
authorChad Horohoe <chadh@wikimedia.org>
Thu, 13 Mar 2014 01:27:58 +0000 (18:27 -0700)
committerChad Horohoe <chadh@wikimedia.org>
Thu, 13 Mar 2014 01:28:47 +0000 (18:28 -0700)
Shouldn't be needed and aren't for any core operations. If any
extension relies on these $wgTitles being set in maintenance
environments those extensions are broken and should be fixed.

Change-Id: Ie02a5042ab96e155d783d56d5340dd0da8e3d55c

maintenance/doMaintenance.php
maintenance/install.php
maintenance/namespaceDupes.php
maintenance/orphans.php
maintenance/rebuildFileCache.php
maintenance/rebuildtextindex.php
maintenance/runJobs.php
maintenance/update.php

index 978d44f..2b637cb 100644 (file)
@@ -99,9 +99,6 @@ $maintenance->finalSetup();
 // Some last includes
 require_once "$IP/includes/Setup.php";
 
-// Much much faster startup than creating a title object
-$wgTitle = null;
-
 // Do the work
 try {
        $maintenance->execute();
index d118747..44c117e 100644 (file)
@@ -70,10 +70,9 @@ class CommandLineInstaller extends Maintenance {
        }
 
        function execute() {
-               global $IP, $wgTitle;
+               global $IP;
                $siteName = isset( $this->mArgs[0] ) ? $this->mArgs[0] : "Don't care"; // Will not be set if used with --env-checks
                $adminName = isset( $this->mArgs[1] ) ? $this->mArgs[1] : null;
-               $wgTitle = Title::newFromText( 'Installer script' );
 
                $dbpassfile = $this->getOption( 'dbpassfile', false );
                if ( $dbpassfile !== false ) {
index ff02468..95d2c08 100644 (file)
@@ -50,10 +50,7 @@ class NamespaceConflictChecker extends Maintenance {
        }
 
        public function execute() {
-               global $wgTitle;
-
                $this->db = wfGetDB( DB_MASTER );
-               $wgTitle = Title::newFromText( 'Namespace title conflict cleanup script' );
 
                $fix = $this->hasOption( 'fix' );
                $suffix = $this->getOption( 'suffix', '' );
index b4d255a..b856baf 100644 (file)
@@ -47,8 +47,6 @@ class Orphans extends Maintenance {
        }
 
        public function execute() {
-               global $wgTitle;
-               $wgTitle = Title::newFromText( 'Orphan revision cleanup script' );
                $this->checkOrphans( $this->hasOption( 'fix' ) );
                $this->checkSeparation( $this->hasOption( 'fix' ) );
                # Does not work yet, do not use
index 12ed9fa..6ce54b9 100644 (file)
@@ -49,7 +49,7 @@ class RebuildFileCache extends Maintenance {
 
        public function execute() {
                global $wgUseFileCache, $wgReadOnly, $wgContentNamespaces, $wgRequestTime;
-               global $wgTitle, $wgOut;
+               global $wgOut;
                if ( !$wgUseFileCache ) {
                        $this->error( "Nothing to do -- \$wgUseFileCache is disabled.", true );
                }
@@ -104,22 +104,22 @@ class RebuildFileCache extends Maintenance {
                                $rebuilt = false;
                                $wgRequestTime = microtime( true ); # bug 22852
 
-                               $wgTitle = Title::makeTitleSafe( $row->page_namespace, $row->page_title );
-                               if ( null == $wgTitle ) {
+                               $title = Title::makeTitleSafe( $row->page_namespace, $row->page_title );
+                               if ( null == $title ) {
                                        $this->output( "Page {$row->page_id} has bad title\n" );
                                        continue; // broken title?
                                }
 
                                $context = new RequestContext;
-                               $context->setTitle( $wgTitle );
-                               $article = Article::newFromTitle( $wgTitle, $context );
+                               $context->setTitle( $title );
+                               $article = Article::newFromTitle( $title, $context );
                                $context->setWikiPage( $article->getPage() );
 
                                $wgOut = $context->getOutput(); // set display title
 
                                // If the article is cacheable, then load it
                                if ( $article->isFileCacheable() ) {
-                                       $cache = HTMLFileCache::newFromTitle( $wgTitle, 'view' );
+                                       $cache = HTMLFileCache::newFromTitle( $title, 'view' );
                                        if ( $cache->isCacheGood() ) {
                                                if ( $overwrite ) {
                                                        $rebuilt = true;
@@ -151,11 +151,6 @@ class RebuildFileCache extends Maintenance {
                        $blockEnd += $this->mBatchSize;
                }
                $this->output( "Done!\n" );
-
-               // Remove these to be safe
-               if ( isset( $wgTitle ) ) {
-                       unset( $wgTitle );
-               }
        }
 }
 
index c651f72..722db26 100644 (file)
@@ -50,8 +50,6 @@ class RebuildTextIndex extends Maintenance {
        }
 
        public function execute() {
-               global $wgTitle;
-
                // Shouldn't be needed for Postgres
                $this->db = wfGetDB( DB_MASTER );
                if ( $this->db->getType() == 'postgres' ) {
@@ -68,8 +66,6 @@ class RebuildTextIndex extends Maintenance {
                        }
                }
 
-               $wgTitle = Title::newFromText( "Rebuild text index script" );
-
                if ( $this->db->getType() == 'mysql' ) {
                        $this->dropMysqlTextIndex();
                        $this->populateSearchIndex();
index 7c896d2..f7d5fc0 100644 (file)
@@ -47,8 +47,6 @@ class RunJobs extends Maintenance {
        }
 
        public function execute() {
-               global $wgTitle;
-
                if ( wfReadOnly() ) {
                        $this->error( "Unable to run jobs; the wiki is in read-only mode.", 1 ); // die
                }
@@ -69,7 +67,6 @@ class RunJobs extends Maintenance {
                $maxJobs = $this->getOption( 'maxjobs', false );
                $maxTime = $this->getOption( 'maxtime', false );
                $startTime = time();
-               $wgTitle = Title::newFromText( 'RunJobs.php' );
 
                $group = JobQueueGroup::singleton();
                // Handle any required periodic queue maintenance
index 85364ee..8c1ad17 100644 (file)
@@ -83,7 +83,7 @@ class UpdateMediaWiki extends Maintenance {
        }
 
        function execute() {
-               global $wgVersion, $wgTitle, $wgLang, $wgAllowSchemaUpdates;
+               global $wgVersion, $wgLang, $wgAllowSchemaUpdates;
 
                if ( !$wgAllowSchemaUpdates && !( $this->hasOption( 'force' ) || $this->hasOption( 'schema' ) || $this->hasOption( 'noschema' ) ) ) {
                        $this->error( "Do not run update.php on this wiki. If you're seeing this you should\n"
@@ -106,7 +106,6 @@ class UpdateMediaWiki extends Maintenance {
                }
 
                $wgLang = Language::factory( 'en' );
-               $wgTitle = Title::newFromText( "MediaWiki database updater" );
 
                define( 'MW_UPDATER', true );