From 8f1d2cb19924b3ade08c527bd79c308c8f9de79b Mon Sep 17 00:00:00 2001 From: Sam Reed Date: Thu, 22 Jul 2010 22:13:21 +0000 Subject: [PATCH] Big blitz on unused variables (a lot of $db = $this->getDb() ) --- includes/api/ApiBase.php | 2 +- includes/api/ApiMove.php | 7 ++----- includes/api/ApiParse.php | 1 - includes/api/ApiQueryAllUsers.php | 1 - includes/api/ApiQueryAllmessages.php | 1 - includes/api/ApiQueryBacklinks.php | 2 -- includes/api/ApiQueryBlocks.php | 3 --- includes/api/ApiQueryCategories.php | 1 - includes/api/ApiQueryCategoryInfo.php | 1 - includes/api/ApiQueryCategoryMembers.php | 3 --- includes/api/ApiQueryDeletedrevs.php | 1 - includes/api/ApiQueryDuplicateFiles.php | 1 - includes/api/ApiQueryExternalLinks.php | 1 - includes/api/ApiQueryFilearchive.php | 2 -- includes/api/ApiQueryIWBacklinks.php | 1 - includes/api/ApiQueryIWLinks.php | 1 - includes/api/ApiQueryImages.php | 1 - includes/api/ApiQueryInfo.php | 3 --- includes/api/ApiQueryLangLinks.php | 1 - includes/api/ApiQueryLinks.php | 1 - includes/api/ApiQueryLogEvents.php | 2 -- includes/api/ApiQueryProtectedTitles.php | 1 - includes/api/ApiQueryRandom.php | 1 - includes/api/ApiQueryRecentChanges.php | 2 -- includes/api/ApiQueryRevisions.php | 1 - includes/api/ApiQuerySiteinfo.php | 3 +-- includes/api/ApiQueryTags.php | 4 ---- includes/api/ApiQueryUserContributions.php | 1 - includes/api/ApiQueryUsers.php | 2 -- includes/api/ApiQueryWatchlistRaw.php | 1 - 30 files changed, 4 insertions(+), 49 deletions(-) diff --git a/includes/api/ApiBase.php b/includes/api/ApiBase.php index 9a24d0ed2d..12d5de1085 100644 --- a/includes/api/ApiBase.php +++ b/includes/api/ApiBase.php @@ -843,7 +843,7 @@ abstract class ApiBase { public static function truncateArray( &$arr, $limit ) { $modified = false; while ( count( $arr ) > $limit ) { - $junk = array_pop( $arr ); + array_pop( $arr ); $modified = true; } return $modified; diff --git a/includes/api/ApiMove.php b/includes/api/ApiMove.php index ac07471b62..9b6017105e 100644 --- a/includes/api/ApiMove.php +++ b/includes/api/ApiMove.php @@ -84,21 +84,18 @@ class ApiMove extends ApiBase { } // Move the page - $hookErr = null; $retval = $fromTitle->moveTo( $toTitle, true, $params['reason'], !$params['noredirect'] ); if ( $retval !== true ) { $this->dieUsageMsg( reset( $retval ) ); } $r = array( 'from' => $fromTitle->getPrefixedText(), 'to' => $toTitle->getPrefixedText(), 'reason' => $params['reason'] ); - if ( !$params['noredirect'] || !$wgUser->isAllowed( 'suppressredirect' ) ) - { + if ( !$params['noredirect'] || !$wgUser->isAllowed( 'suppressredirect' ) ) { $r['redirectcreated'] = ''; } // Move the talk page - if ( $params['movetalk'] && $fromTalk->exists() && !$fromTitle->isTalkPage() ) - { + if ( $params['movetalk'] && $fromTalk->exists() && !$fromTitle->isTalkPage() ) { $retval = $fromTalk->moveTo( $toTalk, true, $params['reason'], !$params['noredirect'] ); if ( $retval === true ) { $r['talkfrom'] = $fromTalk->getPrefixedText(); diff --git a/includes/api/ApiParse.php b/includes/api/ApiParse.php index 01285ecf55..ae419a8d42 100644 --- a/includes/api/ApiParse.php +++ b/includes/api/ApiParse.php @@ -50,7 +50,6 @@ class ApiParse extends ApiBase { $this->dieUsage( 'The page parameter cannot be used together with the text and title parameters', 'params' ); } $prop = array_flip( $params['prop'] ); - $revid = false; if ( isset( $params['section'] ) ) { $this->section = $params['section']; diff --git a/includes/api/ApiQueryAllUsers.php b/includes/api/ApiQueryAllUsers.php index dd2e7cecae..9354745291 100644 --- a/includes/api/ApiQueryAllUsers.php +++ b/includes/api/ApiQueryAllUsers.php @@ -116,7 +116,6 @@ class ApiQueryAllUsers extends ApiQueryBase { $res = $this->select( __METHOD__ ); - $data = array(); $count = 0; $lastUserData = false; $lastUser = false; diff --git a/includes/api/ApiQueryAllmessages.php b/includes/api/ApiQueryAllmessages.php index 5184ecf669..6e5cbd2903 100644 --- a/includes/api/ApiQueryAllmessages.php +++ b/includes/api/ApiQueryAllmessages.php @@ -78,7 +78,6 @@ class ApiQueryAllmessages extends ApiQueryBase { } // Get all requested messages and print the result - $messages = array(); $skip = !is_null( $params['from'] ); $result = $this->getResult(); foreach ( $messages_target as $message ) { diff --git a/includes/api/ApiQueryBacklinks.php b/includes/api/ApiQueryBacklinks.php index 92b1a638b5..aed143af84 100644 --- a/includes/api/ApiQueryBacklinks.php +++ b/includes/api/ApiQueryBacklinks.php @@ -102,7 +102,6 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase { * AND pl_title='Foo' AND pl_namespace=0 * LIMIT 11 ORDER BY pl_from */ - $db = $this->getDB(); $this->addTables( array( $this->bl_table, 'page' ) ); $this->addWhere( "{$this->bl_from}=page_id" ); if ( is_null( $resultPageSet ) ) { @@ -206,7 +205,6 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase { $this->processContinue(); $this->prepareFirstQuery( $resultPageSet ); - $db = $this->getDB(); $res = $this->select( __METHOD__ . '::firstQuery' ); $count = 0; diff --git a/includes/api/ApiQueryBlocks.php b/includes/api/ApiQueryBlocks.php index fc5e3b73f1..2db17bd87c 100644 --- a/includes/api/ApiQueryBlocks.php +++ b/includes/api/ApiQueryBlocks.php @@ -60,9 +60,6 @@ class ApiQueryBlocks extends ApiQueryBase { $fld_flags = isset( $prop['flags'] ); $result = $this->getResult(); - $pageSet = $this->getPageSet(); - $titles = $pageSet->getTitles(); - $data = array(); $this->addTables( 'ipblocks' ); $this->addFields( 'ipb_auto' ); diff --git a/includes/api/ApiQueryCategories.php b/includes/api/ApiQueryCategories.php index ea1e6e82bd..0d6c15fc88 100644 --- a/includes/api/ApiQueryCategories.php +++ b/includes/api/ApiQueryCategories.php @@ -125,7 +125,6 @@ class ApiQueryCategories extends ApiQueryGeneratorBase { $this->addOption( 'ORDER BY', "cl_from, cl_to" ); } - $db = $this->getDB(); $res = $this->select( __METHOD__ ); if ( is_null( $resultPageSet ) ) { diff --git a/includes/api/ApiQueryCategoryInfo.php b/includes/api/ApiQueryCategoryInfo.php index 3f4348d310..a89a0e1a08 100644 --- a/includes/api/ApiQueryCategoryInfo.php +++ b/includes/api/ApiQueryCategoryInfo.php @@ -74,7 +74,6 @@ class ApiQueryCategoryInfo extends ApiQueryBase { } $this->addOption( 'ORDER BY', 'cat_title' ); - $db = $this->getDB(); $res = $this->select( __METHOD__ ); $catids = array_flip( $cattitles ); diff --git a/includes/api/ApiQueryCategoryMembers.php b/includes/api/ApiQueryCategoryMembers.php index a09222444e..5eb65f1cbd 100644 --- a/includes/api/ApiQueryCategoryMembers.php +++ b/includes/api/ApiQueryCategoryMembers.php @@ -104,9 +104,6 @@ class ApiQueryCategoryMembers extends ApiQueryGeneratorBase { $limit = $params['limit']; $this->addOption( 'LIMIT', $limit + 1 ); - $db = $this->getDB(); - - $data = array(); $count = 0; $lastSortKey = null; $res = $this->select( __METHOD__ ); diff --git a/includes/api/ApiQueryDeletedrevs.php b/includes/api/ApiQueryDeletedrevs.php index f940ff03e8..598584444c 100644 --- a/includes/api/ApiQueryDeletedrevs.php +++ b/includes/api/ApiQueryDeletedrevs.php @@ -62,7 +62,6 @@ class ApiQueryDeletedrevs extends ApiQueryBase { $result = $this->getResult(); $pageSet = $this->getPageSet(); $titles = $pageSet->getTitles(); - $data = array(); // This module operates in three modes: // 'revs': List deleted revs for certain titles diff --git a/includes/api/ApiQueryDuplicateFiles.php b/includes/api/ApiQueryDuplicateFiles.php index 0f5372cc19..cdc63d7bd4 100644 --- a/includes/api/ApiQueryDuplicateFiles.php +++ b/includes/api/ApiQueryDuplicateFiles.php @@ -89,7 +89,6 @@ class ApiQueryDuplicateFiles extends ApiQueryGeneratorBase { $this->addOption( 'LIMIT', $params['limit'] + 1 ); $res = $this->select( __METHOD__ ); - $db = $this->getDB(); $count = 0; $titles = array(); foreach ( $res as $row ) { diff --git a/includes/api/ApiQueryExternalLinks.php b/includes/api/ApiQueryExternalLinks.php index 77b0e4815b..a679c47149 100644 --- a/includes/api/ApiQueryExternalLinks.php +++ b/includes/api/ApiQueryExternalLinks.php @@ -63,7 +63,6 @@ class ApiQueryExternalLinks extends ApiQueryBase { $this->addOption( 'OFFSET', $params['offset'] ); } - $db = $this->getDB(); $res = $this->select( __METHOD__ ); $count = 0; diff --git a/includes/api/ApiQueryFilearchive.php b/includes/api/ApiQueryFilearchive.php index d23c91144e..38ca3d977d 100644 --- a/includes/api/ApiQueryFilearchive.php +++ b/includes/api/ApiQueryFilearchive.php @@ -54,7 +54,6 @@ class ApiQueryFilearchive extends ApiQueryBase { $params = $this->extractRequestParams(); $prop = array_flip( $params['prop'] ); - $fld_id = isset( $prop['id'] ); $fld_sha1 = isset( $prop['sha1'] ); $fld_timestamp = isset( $prop['timestamp'] ); $fld_user = isset( $prop['user'] ); @@ -118,7 +117,6 @@ class ApiQueryFilearchive extends ApiQueryBase { $res = $this->select( __METHOD__ ); - $titles = array(); $count = 0; $result = $this->getResult(); foreach ( $res as $row ) { diff --git a/includes/api/ApiQueryIWBacklinks.php b/includes/api/ApiQueryIWBacklinks.php index e593f4e15a..35baa48ef3 100644 --- a/includes/api/ApiQueryIWBacklinks.php +++ b/includes/api/ApiQueryIWBacklinks.php @@ -97,7 +97,6 @@ class ApiQueryIWBacklinks extends ApiQueryGeneratorBase { $this->addOption( 'LIMIT', $params['limit'] + 1 ); - $db = $this->getDB(); $res = $this->select( __METHOD__ ); $pages = array(); diff --git a/includes/api/ApiQueryIWLinks.php b/includes/api/ApiQueryIWLinks.php index f33606f454..03288a9beb 100644 --- a/includes/api/ApiQueryIWLinks.php +++ b/includes/api/ApiQueryIWLinks.php @@ -83,7 +83,6 @@ class ApiQueryIWLinks extends ApiQueryBase { $res = $this->select( __METHOD__ ); $count = 0; - $db = $this->getDB(); foreach ( $res as $row ) { if ( ++$count > $params['limit'] ) { // We've reached the one extra which shows that diff --git a/includes/api/ApiQueryImages.php b/includes/api/ApiQueryImages.php index 1f1e716aba..b961d882ec 100644 --- a/includes/api/ApiQueryImages.php +++ b/includes/api/ApiQueryImages.php @@ -83,7 +83,6 @@ class ApiQueryImages extends ApiQueryGeneratorBase { } $this->addOption( 'LIMIT', $params['limit'] + 1 ); - $db = $this->getDB(); $res = $this->select( __METHOD__ ); if ( is_null( $resultPageSet ) ) { diff --git a/includes/api/ApiQueryInfo.php b/includes/api/ApiQueryInfo.php index 12f47d35bc..896e200bb9 100644 --- a/includes/api/ApiQueryInfo.php +++ b/includes/api/ApiQueryInfo.php @@ -247,7 +247,6 @@ class ApiQueryInfo extends ApiQueryBase { $this->pageLatest = $pageSet->getCustomField( 'page_latest' ); $this->pageLength = $pageSet->getCustomField( 'page_len' ); - $db = $this->getDB(); // Get protection info if requested if ( $this->fld_protection ) { $this->getProtectionInfo(); @@ -563,8 +562,6 @@ class ApiQueryInfo extends ApiQueryBase { if ( !count( $pageIds ) ) { return; } - - $db = $this->getDB(); $this->resetQueryParams(); $this->addTables( 'page_props' ); diff --git a/includes/api/ApiQueryLangLinks.php b/includes/api/ApiQueryLangLinks.php index 188a8a2f31..5e36bcac1a 100644 --- a/includes/api/ApiQueryLangLinks.php +++ b/includes/api/ApiQueryLangLinks.php @@ -78,7 +78,6 @@ class ApiQueryLangLinks extends ApiQueryBase { $res = $this->select( __METHOD__ ); $count = 0; - $db = $this->getDB(); foreach ( $res as $row ) { if ( ++$count > $params['limit'] ) { // We've reached the one extra which shows that diff --git a/includes/api/ApiQueryLinks.php b/includes/api/ApiQueryLinks.php index aa76559cb9..9e5b75dde9 100644 --- a/includes/api/ApiQueryLinks.php +++ b/includes/api/ApiQueryLinks.php @@ -138,7 +138,6 @@ class ApiQueryLinks extends ApiQueryGeneratorBase { $this->addOption( 'USE INDEX', "{$this->prefix}_from" ); $this->addOption( 'LIMIT', $params['limit'] + 1 ); - $db = $this->getDB(); $res = $this->select( __METHOD__ ); if ( is_null( $resultPageSet ) ) { diff --git a/includes/api/ApiQueryLogEvents.php b/includes/api/ApiQueryLogEvents.php index f0fd2119e5..51ca8b655f 100644 --- a/includes/api/ApiQueryLogEvents.php +++ b/includes/api/ApiQueryLogEvents.php @@ -56,8 +56,6 @@ class ApiQueryLogEvents extends ApiQueryBase { $this->fld_details = isset( $prop['details'] ); $this->fld_tags = isset( $prop['tags'] ); - list( $tbl_logging, $tbl_page, $tbl_user ) = $db->tableNamesN( 'logging', 'page', 'user' ); - $hideLogs = LogEventsList::getExcludeClause( $db ); if ( $hideLogs !== false ) { $this->addWhere( $hideLogs ); diff --git a/includes/api/ApiQueryProtectedTitles.php b/includes/api/ApiQueryProtectedTitles.php index 5354e61580..19b8182b56 100644 --- a/includes/api/ApiQueryProtectedTitles.php +++ b/includes/api/ApiQueryProtectedTitles.php @@ -48,7 +48,6 @@ class ApiQueryProtectedTitles extends ApiQueryGeneratorBase { } private function run( $resultPageSet = null ) { - $db = $this->getDB(); $params = $this->extractRequestParams(); $this->addTables( 'protected_titles' ); diff --git a/includes/api/ApiQueryRandom.php b/includes/api/ApiQueryRandom.php index bcef77a578..41aef1a022 100644 --- a/includes/api/ApiQueryRandom.php +++ b/includes/api/ApiQueryRandom.php @@ -64,7 +64,6 @@ if ( !defined( 'MEDIAWIKI' ) ) { } protected function runQuery( &$resultPageSet ) { - $db = $this->getDB(); $res = $this->select( __METHOD__ ); $count = 0; foreach ( $res as $row ) { diff --git a/includes/api/ApiQueryRecentChanges.php b/includes/api/ApiQueryRecentChanges.php index 33021cd795..b0d7e837fd 100644 --- a/includes/api/ApiQueryRecentChanges.php +++ b/includes/api/ApiQueryRecentChanges.php @@ -116,7 +116,6 @@ class ApiQueryRecentChanges extends ApiQueryBase { * AND rc_timestamp < $end AND rc_namespace = $namespace * AND rc_deleted = '0' */ - $db = $this->getDB(); $this->addTables( 'recentchanges' ); $index = array( 'recentchanges' => 'rc_timestamp' ); // May change $this->addWhereRange( 'rc_timestamp', $params['dir'], $params['start'], $params['end'] ); @@ -250,7 +249,6 @@ class ApiQueryRecentChanges extends ApiQueryBase { $count = 0; /* Perform the actual query. */ - $db = $this->getDB(); $res = $this->select( __METHOD__ ); /* Iterate through the rows, adding data extracted from them to our query result. */ diff --git a/includes/api/ApiQueryRevisions.php b/includes/api/ApiQueryRevisions.php index d4f89e2324..1a79e7e534 100644 --- a/includes/api/ApiQueryRevisions.php +++ b/includes/api/ApiQueryRevisions.php @@ -318,7 +318,6 @@ class ApiQueryRevisions extends ApiQueryBase { $this->addOption( 'LIMIT', $limit + 1 ); $this->addOption( 'USE INDEX', $index ); - $data = array(); $count = 0; $res = $this->select( __METHOD__ ); diff --git a/includes/api/ApiQuerySiteinfo.php b/includes/api/ApiQuerySiteinfo.php index 092aaababb..0bfd3c3a52 100644 --- a/includes/api/ApiQuerySiteinfo.php +++ b/includes/api/ApiQuerySiteinfo.php @@ -252,8 +252,7 @@ class ApiQuerySiteinfo extends ApiQueryBase { $this->addOption( 'ORDER BY', 'iw_prefix' ); - $db = $this->getDB(); - $res = $this->select( __METHOD__ ); + $res = $this->select( __METHOD__ ); $data = array(); $langNames = Language::getLanguageNames(); diff --git a/includes/api/ApiQueryTags.php b/includes/api/ApiQueryTags.php index 1c64ebcaed..ad708bd44c 100644 --- a/includes/api/ApiQueryTags.php +++ b/includes/api/ApiQueryTags.php @@ -55,10 +55,6 @@ class ApiQueryTags extends ApiQueryBase { $this->limit = $params['limit']; $this->result = $this->getResult(); - $pageSet = $this->getPageSet(); - $titles = $pageSet->getTitles(); - $data = array(); - $this->addTables( 'change_tag' ); $this->addFields( 'ct_tag' ); diff --git a/includes/api/ApiQueryUserContributions.php b/includes/api/ApiQueryUserContributions.php index 85c1d770bd..c6eadb22bc 100644 --- a/includes/api/ApiQueryUserContributions.php +++ b/includes/api/ApiQueryUserContributions.php @@ -61,7 +61,6 @@ class ApiQueryContributions extends ApiQueryBase { // TODO: if the query is going only against the revision table, should this be done? $this->selectNamedDB( 'contributions', DB_SLAVE, 'contributions' ); - $db = $this->getDB(); if ( isset( $this->params['userprefix'] ) ) { $this->prefixMode = true; diff --git a/includes/api/ApiQueryUsers.php b/includes/api/ApiQueryUsers.php index 0a233a727b..b50fe71906 100644 --- a/includes/api/ApiQueryUsers.php +++ b/includes/api/ApiQueryUsers.php @@ -73,7 +73,6 @@ if ( !defined( 'MEDIAWIKI' ) ) { public function execute() { $params = $this->extractRequestParams(); $result = $this->getResult(); - $r = array(); if ( !is_null( $params['prop'] ) ) { $this->prop = array_flip( $params['prop'] ); @@ -104,7 +103,6 @@ if ( !defined( 'MEDIAWIKI' ) ) { } if ( count( $goodNames ) ) { - $db = $this->getDb(); $this->addTables( 'user', 'u1' ); $this->addFields( 'u1.*' ); $this->addWhereFld( 'u1.user_name', $goodNames ); diff --git a/includes/api/ApiQueryWatchlistRaw.php b/includes/api/ApiQueryWatchlistRaw.php index 0a916dfb8f..df1034058c 100644 --- a/includes/api/ApiQueryWatchlistRaw.php +++ b/includes/api/ApiQueryWatchlistRaw.php @@ -93,7 +93,6 @@ class ApiQueryWatchlistRaw extends ApiQueryGeneratorBase { $this->addOption( 'LIMIT', $params['limit'] + 1 ); $res = $this->select( __METHOD__ ); - $db = $this->getDB(); $titles = array(); $count = 0; foreach ( $res as $row ) { -- 2.20.1