Big blitz on unused variables (a lot of $db = $this->getDb() )
authorSam Reed <reedy@users.mediawiki.org>
Thu, 22 Jul 2010 22:13:21 +0000 (22:13 +0000)
committerSam Reed <reedy@users.mediawiki.org>
Thu, 22 Jul 2010 22:13:21 +0000 (22:13 +0000)
30 files changed:
includes/api/ApiBase.php
includes/api/ApiMove.php
includes/api/ApiParse.php
includes/api/ApiQueryAllUsers.php
includes/api/ApiQueryAllmessages.php
includes/api/ApiQueryBacklinks.php
includes/api/ApiQueryBlocks.php
includes/api/ApiQueryCategories.php
includes/api/ApiQueryCategoryInfo.php
includes/api/ApiQueryCategoryMembers.php
includes/api/ApiQueryDeletedrevs.php
includes/api/ApiQueryDuplicateFiles.php
includes/api/ApiQueryExternalLinks.php
includes/api/ApiQueryFilearchive.php
includes/api/ApiQueryIWBacklinks.php
includes/api/ApiQueryIWLinks.php
includes/api/ApiQueryImages.php
includes/api/ApiQueryInfo.php
includes/api/ApiQueryLangLinks.php
includes/api/ApiQueryLinks.php
includes/api/ApiQueryLogEvents.php
includes/api/ApiQueryProtectedTitles.php
includes/api/ApiQueryRandom.php
includes/api/ApiQueryRecentChanges.php
includes/api/ApiQueryRevisions.php
includes/api/ApiQuerySiteinfo.php
includes/api/ApiQueryTags.php
includes/api/ApiQueryUserContributions.php
includes/api/ApiQueryUsers.php
includes/api/ApiQueryWatchlistRaw.php

index 9a24d0e..12d5de1 100644 (file)
@@ -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;
index ac07471..9b60171 100644 (file)
@@ -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();
index 01285ec..ae419a8 100644 (file)
@@ -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'];
index dd2e7ce..9354745 100644 (file)
@@ -116,7 +116,6 @@ class ApiQueryAllUsers extends ApiQueryBase {
 
                $res = $this->select( __METHOD__ );
 
-               $data = array();
                $count = 0;
                $lastUserData = false;
                $lastUser = false;
index 5184ecf..6e5cbd2 100644 (file)
@@ -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 ) {
index 92b1a63..aed143a 100644 (file)
@@ -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;
index fc5e3b7..2db17bd 100644 (file)
@@ -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' );
index ea1e6e8..0d6c15f 100644 (file)
@@ -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 ) ) {
index 3f4348d..a89a0e1 100644 (file)
@@ -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 );
index a092224..5eb65f1 100644 (file)
@@ -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__ );
index f940ff0..5985844 100644 (file)
@@ -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
index 0f5372c..cdc63d7 100644 (file)
@@ -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 ) {
index 77b0e48..a679c47 100644 (file)
@@ -63,7 +63,6 @@ class ApiQueryExternalLinks extends ApiQueryBase {
                        $this->addOption( 'OFFSET', $params['offset'] );
                }
 
-               $db = $this->getDB();
                $res = $this->select( __METHOD__ );
 
                $count = 0;
index d23c911..38ca3d9 100644 (file)
@@ -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 ) {
index e593f4e..35baa48 100644 (file)
@@ -97,7 +97,6 @@ class ApiQueryIWBacklinks extends ApiQueryGeneratorBase {
 
                $this->addOption( 'LIMIT', $params['limit'] + 1 );
 
-               $db = $this->getDB();
                $res = $this->select( __METHOD__ );
                
                $pages = array();
index f33606f..03288a9 100644 (file)
@@ -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
index 1f1e716..b961d88 100644 (file)
@@ -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 ) ) {
index 12f47d3..896e200 100644 (file)
@@ -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' );
index 188a8a2..5e36bca 100644 (file)
@@ -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
index aa76559..9e5b75d 100644 (file)
@@ -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 ) ) {
index f0fd211..51ca8b6 100644 (file)
@@ -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 );
index 5354e61..19b8182 100644 (file)
@@ -48,7 +48,6 @@ class ApiQueryProtectedTitles extends ApiQueryGeneratorBase {
        }
 
        private function run( $resultPageSet = null ) {
-               $db = $this->getDB();
                $params = $this->extractRequestParams();
 
                $this->addTables( 'protected_titles' );
index bcef77a..41aef1a 100644 (file)
@@ -64,7 +64,6 @@ if ( !defined( 'MEDIAWIKI' ) ) {
        }
 
        protected function runQuery( &$resultPageSet ) {
-               $db = $this->getDB();
                $res = $this->select( __METHOD__ );
                $count = 0;
                foreach ( $res as $row ) {
index 33021cd..b0d7e83 100644 (file)
@@ -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. */
index d4f89e2..1a79e7e 100644 (file)
@@ -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__ );
 
index 092aaab..0bfd3c3 100644 (file)
@@ -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();
index 1c64ebc..ad708bd 100644 (file)
@@ -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' );
 
index 85c1d77..c6eadb2 100644 (file)
@@ -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;
index 0a233a7..b50fe71 100644 (file)
@@ -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 );
index 0a916df..df10340 100644 (file)
@@ -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 ) {