From 518fa756f2301ff2ee7890d6dc3726792252efd9 Mon Sep 17 00:00:00 2001 From: Chad Horohoe Date: Wed, 12 Mar 2014 18:27:58 -0700 Subject: [PATCH] Remove $wgTitle from all maintenance scripts 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 | 3 --- maintenance/install.php | 3 +-- maintenance/namespaceDupes.php | 3 --- maintenance/orphans.php | 2 -- maintenance/rebuildFileCache.php | 17 ++++++----------- maintenance/rebuildtextindex.php | 4 ---- maintenance/runJobs.php | 3 --- maintenance/update.php | 3 +-- 8 files changed, 8 insertions(+), 30 deletions(-) diff --git a/maintenance/doMaintenance.php b/maintenance/doMaintenance.php index 978d44f586..2b637cb707 100644 --- a/maintenance/doMaintenance.php +++ b/maintenance/doMaintenance.php @@ -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(); diff --git a/maintenance/install.php b/maintenance/install.php index d118747aff..44c117efde 100644 --- a/maintenance/install.php +++ b/maintenance/install.php @@ -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 ) { diff --git a/maintenance/namespaceDupes.php b/maintenance/namespaceDupes.php index ff024682c6..95d2c08a2a 100644 --- a/maintenance/namespaceDupes.php +++ b/maintenance/namespaceDupes.php @@ -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', '' ); diff --git a/maintenance/orphans.php b/maintenance/orphans.php index b4d255ab8a..b856baf86c 100644 --- a/maintenance/orphans.php +++ b/maintenance/orphans.php @@ -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 diff --git a/maintenance/rebuildFileCache.php b/maintenance/rebuildFileCache.php index 12ed9facaf..6ce54b9f02 100644 --- a/maintenance/rebuildFileCache.php +++ b/maintenance/rebuildFileCache.php @@ -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 ); - } } } diff --git a/maintenance/rebuildtextindex.php b/maintenance/rebuildtextindex.php index c651f720b5..722db26cfe 100644 --- a/maintenance/rebuildtextindex.php +++ b/maintenance/rebuildtextindex.php @@ -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(); diff --git a/maintenance/runJobs.php b/maintenance/runJobs.php index 7c896d2432..f7d5fc07e7 100644 --- a/maintenance/runJobs.php +++ b/maintenance/runJobs.php @@ -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 diff --git a/maintenance/update.php b/maintenance/update.php index 85364ee3a3..8c1ad17450 100644 --- a/maintenance/update.php +++ b/maintenance/update.php @@ -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 ); -- 2.20.1