r69761 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r69760‎ | r69761 | r69762 >
Date:22:13, 22 July 2010
Author:reedy
Status:resolved (Comments)
Tags:
Comment:
Big blitz on unused variables (a lot of $db = $this->getDb() )
Modified paths:
  • /trunk/phase3/includes/api/ApiBase.php (modified) (history)
  • /trunk/phase3/includes/api/ApiMove.php (modified) (history)
  • /trunk/phase3/includes/api/ApiParse.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryAllUsers.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryAllmessages.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryBacklinks.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryBlocks.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryCategories.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryCategoryInfo.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryCategoryMembers.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryDeletedrevs.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryDuplicateFiles.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryExternalLinks.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryFilearchive.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryIWBacklinks.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryIWLinks.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryImages.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryInfo.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryLangLinks.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryLinks.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryLogEvents.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryProtectedTitles.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryRandom.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryRecentChanges.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryRevisions.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQuerySiteinfo.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryTags.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryUserContributions.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryUsers.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryWatchlistRaw.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiQueryAllUsers.php
@@ -116,7 +116,6 @@
117117
118118 $res = $this->select( __METHOD__ );
119119
120 - $data = array();
121120 $count = 0;
122121 $lastUserData = false;
123122 $lastUser = false;
Index: trunk/phase3/includes/api/ApiQueryInfo.php
@@ -247,7 +247,6 @@
248248 $this->pageLatest = $pageSet->getCustomField( 'page_latest' );
249249 $this->pageLength = $pageSet->getCustomField( 'page_len' );
250250
251 - $db = $this->getDB();
252251 // Get protection info if requested
253252 if ( $this->fld_protection ) {
254253 $this->getProtectionInfo();
@@ -563,8 +562,6 @@
564563 if ( !count( $pageIds ) ) {
565564 return;
566565 }
567 -
568 - $db = $this->getDB();
569566
570567 $this->resetQueryParams();
571568 $this->addTables( 'page_props' );
Index: trunk/phase3/includes/api/ApiQueryTags.php
@@ -55,10 +55,6 @@
5656 $this->limit = $params['limit'];
5757 $this->result = $this->getResult();
5858
59 - $pageSet = $this->getPageSet();
60 - $titles = $pageSet->getTitles();
61 - $data = array();
62 -
6359 $this->addTables( 'change_tag' );
6460 $this->addFields( 'ct_tag' );
6561
Index: trunk/phase3/includes/api/ApiQueryBacklinks.php
@@ -102,7 +102,6 @@
103103 * AND pl_title='Foo' AND pl_namespace=0
104104 * LIMIT 11 ORDER BY pl_from
105105 */
106 - $db = $this->getDB();
107106 $this->addTables( array( $this->bl_table, 'page' ) );
108107 $this->addWhere( "{$this->bl_from}=page_id" );
109108 if ( is_null( $resultPageSet ) ) {
@@ -206,7 +205,6 @@
207206 $this->processContinue();
208207 $this->prepareFirstQuery( $resultPageSet );
209208
210 - $db = $this->getDB();
211209 $res = $this->select( __METHOD__ . '::firstQuery' );
212210
213211 $count = 0;
Index: trunk/phase3/includes/api/ApiQueryIWBacklinks.php
@@ -97,7 +97,6 @@
9898
9999 $this->addOption( 'LIMIT', $params['limit'] + 1 );
100100
101 - $db = $this->getDB();
102101 $res = $this->select( __METHOD__ );
103102
104103 $pages = array();
Index: trunk/phase3/includes/api/ApiQuerySiteinfo.php
@@ -252,8 +252,7 @@
253253
254254 $this->addOption( 'ORDER BY', 'iw_prefix' );
255255
256 - $db = $this->getDB();
257 - $res = $this->select( __METHOD__ );
 256+ $res = $this->select( __METHOD__ );
258257
259258 $data = array();
260259 $langNames = Language::getLanguageNames();
Index: trunk/phase3/includes/api/ApiParse.php
@@ -50,7 +50,6 @@
5151 $this->dieUsage( 'The page parameter cannot be used together with the text and title parameters', 'params' );
5252 }
5353 $prop = array_flip( $params['prop'] );
54 - $revid = false;
5554
5655 if ( isset( $params['section'] ) ) {
5756 $this->section = $params['section'];
Index: trunk/phase3/includes/api/ApiBase.php
@@ -843,7 +843,7 @@
844844 public static function truncateArray( &$arr, $limit ) {
845845 $modified = false;
846846 while ( count( $arr ) > $limit ) {
847 - $junk = array_pop( $arr );
 847+ array_pop( $arr );
848848 $modified = true;
849849 }
850850 return $modified;
Index: trunk/phase3/includes/api/ApiQueryLogEvents.php
@@ -56,8 +56,6 @@
5757 $this->fld_details = isset( $prop['details'] );
5858 $this->fld_tags = isset( $prop['tags'] );
5959
60 - list( $tbl_logging, $tbl_page, $tbl_user ) = $db->tableNamesN( 'logging', 'page', 'user' );
61 -
6260 $hideLogs = LogEventsList::getExcludeClause( $db );
6361 if ( $hideLogs !== false ) {
6462 $this->addWhere( $hideLogs );
Index: trunk/phase3/includes/api/ApiMove.php
@@ -84,21 +84,18 @@
8585 }
8686
8787 // Move the page
88 - $hookErr = null;
8988 $retval = $fromTitle->moveTo( $toTitle, true, $params['reason'], !$params['noredirect'] );
9089 if ( $retval !== true ) {
9190 $this->dieUsageMsg( reset( $retval ) );
9291 }
9392
9493 $r = array( 'from' => $fromTitle->getPrefixedText(), 'to' => $toTitle->getPrefixedText(), 'reason' => $params['reason'] );
95 - if ( !$params['noredirect'] || !$wgUser->isAllowed( 'suppressredirect' ) )
96 - {
 94+ if ( !$params['noredirect'] || !$wgUser->isAllowed( 'suppressredirect' ) ) {
9795 $r['redirectcreated'] = '';
9896 }
9997
10098 // Move the talk page
101 - if ( $params['movetalk'] && $fromTalk->exists() && !$fromTitle->isTalkPage() )
102 - {
 99+ if ( $params['movetalk'] && $fromTalk->exists() && !$fromTitle->isTalkPage() ) {
103100 $retval = $fromTalk->moveTo( $toTalk, true, $params['reason'], !$params['noredirect'] );
104101 if ( $retval === true ) {
105102 $r['talkfrom'] = $fromTalk->getPrefixedText();
Index: trunk/phase3/includes/api/ApiQueryLangLinks.php
@@ -78,7 +78,6 @@
7979 $res = $this->select( __METHOD__ );
8080
8181 $count = 0;
82 - $db = $this->getDB();
8382 foreach ( $res as $row ) {
8483 if ( ++$count > $params['limit'] ) {
8584 // We've reached the one extra which shows that
Index: trunk/phase3/includes/api/ApiQueryCategories.php
@@ -125,7 +125,6 @@
126126 $this->addOption( 'ORDER BY', "cl_from, cl_to" );
127127 }
128128
129 - $db = $this->getDB();
130129 $res = $this->select( __METHOD__ );
131130
132131 if ( is_null( $resultPageSet ) ) {
Index: trunk/phase3/includes/api/ApiQueryCategoryInfo.php
@@ -74,7 +74,6 @@
7575 }
7676 $this->addOption( 'ORDER BY', 'cat_title' );
7777
78 - $db = $this->getDB();
7978 $res = $this->select( __METHOD__ );
8079
8180 $catids = array_flip( $cattitles );
Index: trunk/phase3/includes/api/ApiQueryDuplicateFiles.php
@@ -89,7 +89,6 @@
9090 $this->addOption( 'LIMIT', $params['limit'] + 1 );
9191
9292 $res = $this->select( __METHOD__ );
93 - $db = $this->getDB();
9493 $count = 0;
9594 $titles = array();
9695 foreach ( $res as $row ) {
Index: trunk/phase3/includes/api/ApiQueryImages.php
@@ -83,7 +83,6 @@
8484 }
8585 $this->addOption( 'LIMIT', $params['limit'] + 1 );
8686
87 - $db = $this->getDB();
8887 $res = $this->select( __METHOD__ );
8988
9089 if ( is_null( $resultPageSet ) ) {
Index: trunk/phase3/includes/api/ApiQueryDeletedrevs.php
@@ -62,7 +62,6 @@
6363 $result = $this->getResult();
6464 $pageSet = $this->getPageSet();
6565 $titles = $pageSet->getTitles();
66 - $data = array();
6766
6867 // This module operates in three modes:
6968 // 'revs': List deleted revs for certain titles
Index: trunk/phase3/includes/api/ApiQueryWatchlistRaw.php
@@ -93,7 +93,6 @@
9494 $this->addOption( 'LIMIT', $params['limit'] + 1 );
9595 $res = $this->select( __METHOD__ );
9696
97 - $db = $this->getDB();
9897 $titles = array();
9998 $count = 0;
10099 foreach ( $res as $row ) {
Index: trunk/phase3/includes/api/ApiQueryRandom.php
@@ -64,7 +64,6 @@
6565 }
6666
6767 protected function runQuery( &$resultPageSet ) {
68 - $db = $this->getDB();
6968 $res = $this->select( __METHOD__ );
7069 $count = 0;
7170 foreach ( $res as $row ) {
Index: trunk/phase3/includes/api/ApiQueryFilearchive.php
@@ -54,7 +54,6 @@
5555 $params = $this->extractRequestParams();
5656
5757 $prop = array_flip( $params['prop'] );
58 - $fld_id = isset( $prop['id'] );
5958 $fld_sha1 = isset( $prop['sha1'] );
6059 $fld_timestamp = isset( $prop['timestamp'] );
6160 $fld_user = isset( $prop['user'] );
@@ -118,7 +117,6 @@
119118
120119 $res = $this->select( __METHOD__ );
121120
122 - $titles = array();
123121 $count = 0;
124122 $result = $this->getResult();
125123 foreach ( $res as $row ) {
Index: trunk/phase3/includes/api/ApiQueryRevisions.php
@@ -318,7 +318,6 @@
319319 $this->addOption( 'LIMIT', $limit + 1 );
320320 $this->addOption( 'USE INDEX', $index );
321321
322 - $data = array();
323322 $count = 0;
324323 $res = $this->select( __METHOD__ );
325324
Index: trunk/phase3/includes/api/ApiQueryExternalLinks.php
@@ -63,7 +63,6 @@
6464 $this->addOption( 'OFFSET', $params['offset'] );
6565 }
6666
67 - $db = $this->getDB();
6867 $res = $this->select( __METHOD__ );
6968
7069 $count = 0;
Index: trunk/phase3/includes/api/ApiQueryCategoryMembers.php
@@ -104,9 +104,6 @@
105105 $limit = $params['limit'];
106106 $this->addOption( 'LIMIT', $limit + 1 );
107107
108 - $db = $this->getDB();
109 -
110 - $data = array();
111108 $count = 0;
112109 $lastSortKey = null;
113110 $res = $this->select( __METHOD__ );
Index: trunk/phase3/includes/api/ApiQueryAllmessages.php
@@ -78,7 +78,6 @@
7979 }
8080
8181 // Get all requested messages and print the result
82 - $messages = array();
8382 $skip = !is_null( $params['from'] );
8483 $result = $this->getResult();
8584 foreach ( $messages_target as $message ) {
Index: trunk/phase3/includes/api/ApiQueryUsers.php
@@ -73,7 +73,6 @@
7474 public function execute() {
7575 $params = $this->extractRequestParams();
7676 $result = $this->getResult();
77 - $r = array();
7877
7978 if ( !is_null( $params['prop'] ) ) {
8079 $this->prop = array_flip( $params['prop'] );
@@ -104,7 +103,6 @@
105104 }
106105
107106 if ( count( $goodNames ) ) {
108 - $db = $this->getDb();
109107 $this->addTables( 'user', 'u1' );
110108 $this->addFields( 'u1.*' );
111109 $this->addWhereFld( 'u1.user_name', $goodNames );
Index: trunk/phase3/includes/api/ApiQueryUserContributions.php
@@ -61,7 +61,6 @@
6262
6363 // TODO: if the query is going only against the revision table, should this be done?
6464 $this->selectNamedDB( 'contributions', DB_SLAVE, 'contributions' );
65 - $db = $this->getDB();
6665
6766 if ( isset( $this->params['userprefix'] ) ) {
6867 $this->prefixMode = true;
Index: trunk/phase3/includes/api/ApiQueryRecentChanges.php
@@ -116,7 +116,6 @@
117117 * AND rc_timestamp < $end AND rc_namespace = $namespace
118118 * AND rc_deleted = '0'
119119 */
120 - $db = $this->getDB();
121120 $this->addTables( 'recentchanges' );
122121 $index = array( 'recentchanges' => 'rc_timestamp' ); // May change
123122 $this->addWhereRange( 'rc_timestamp', $params['dir'], $params['start'], $params['end'] );
@@ -250,7 +249,6 @@
251250
252251 $count = 0;
253252 /* Perform the actual query. */
254 - $db = $this->getDB();
255253 $res = $this->select( __METHOD__ );
256254
257255 /* Iterate through the rows, adding data extracted from them to our query result. */
Index: trunk/phase3/includes/api/ApiQueryBlocks.php
@@ -60,9 +60,6 @@
6161 $fld_flags = isset( $prop['flags'] );
6262
6363 $result = $this->getResult();
64 - $pageSet = $this->getPageSet();
65 - $titles = $pageSet->getTitles();
66 - $data = array();
6764
6865 $this->addTables( 'ipblocks' );
6966 $this->addFields( 'ipb_auto' );
Index: trunk/phase3/includes/api/ApiQueryProtectedTitles.php
@@ -48,7 +48,6 @@
4949 }
5050
5151 private function run( $resultPageSet = null ) {
52 - $db = $this->getDB();
5352 $params = $this->extractRequestParams();
5453
5554 $this->addTables( 'protected_titles' );
Index: trunk/phase3/includes/api/ApiQueryIWLinks.php
@@ -83,7 +83,6 @@
8484 $res = $this->select( __METHOD__ );
8585
8686 $count = 0;
87 - $db = $this->getDB();
8887 foreach ( $res as $row ) {
8988 if ( ++$count > $params['limit'] ) {
9089 // We've reached the one extra which shows that
Index: trunk/phase3/includes/api/ApiQueryLinks.php
@@ -138,7 +138,6 @@
139139 $this->addOption( 'USE INDEX', "{$this->prefix}_from" );
140140 $this->addOption( 'LIMIT', $params['limit'] + 1 );
141141
142 - $db = $this->getDB();
143142 $res = $this->select( __METHOD__ );
144143
145144 if ( is_null( $resultPageSet ) ) {

Follow-up revisions

RevisionCommit summaryAuthorDate
r69797Resolve minor fixme from r69761reedy15:58, 23 July 2010

Comments

#Comment by Catrope (talk | contribs)   09:35, 23 July 2010

In ApiQuerySiteinfo.php:

-		$res = $this->select( __METHOD__ );
+    	$res = $this->select( __METHOD__ );

Changed tabs to spaces.

Good otherwise.

Status & tagging log