r77393 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r77392‎ | r77393 | r77394 >
Date:16:13, 28 November 2010
Author:reedy
Status:ok (Comments)
Tags:
Comment:
Remove some unused variables and globals
Modified paths:
  • /trunk/phase3/includes/StreamFile.php (modified) (history)
  • /trunk/phase3/includes/db/DatabaseMysql.php (modified) (history)
  • /trunk/phase3/includes/db/LBFactory_Multi.php (modified) (history)
  • /trunk/phase3/includes/parser/LinkHolderArray.php (modified) (history)
  • /trunk/phase3/includes/resourceloader/ResourceLoaderContext.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialBooksources.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialPrefixindex.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialUploadStash.php (modified) (history)
  • /trunk/phase3/maintenance/reassignEdits.php (modified) (history)
  • /trunk/phase3/maintenance/tests/parser/parserTest.inc (modified) (history)
  • /trunk/phase3/maintenance/tests/phpunit/includes/search/SearchUpdateTest.php (modified) (history)
  • /trunk/phase3/maintenance/tests/phpunit/suites/UploadFromUrlTestSuite.php (modified) (history)
  • /trunk/phase3/maintenance/updateDoubleWidthSearch.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/tests/phpunit/includes/search/SearchUpdateTest.php
@@ -28,7 +28,7 @@
2929 }
3030
3131 function updateText( $text ) {
32 - list( $title, $resultText ) = $this->update( $text );
 32+ list( , $resultText ) = $this->update( $text );
3333 $resultText = trim( $resultText ); // abstract from some implementation details
3434 return $resultText;
3535 }
Index: trunk/phase3/maintenance/tests/phpunit/suites/UploadFromUrlTestSuite.php
@@ -14,9 +14,9 @@
1515 }
1616
1717 function setUp() {
18 - global $wgParser, $wgParserConf, $IP, $messageMemc, $wgMemc, $wgDeferredUpdateList,
 18+ global $wgParser, $wgParserConf, $IP, $wgDeferredUpdateList,
1919 $wgUser, $wgLang, $wgOut, $wgRequest, $wgStyleDirectory, $wgEnableParserCache,
20 - $wgMessageCache, $wgUseDatabaseMessages, $wgMsgCacheExpiry, $parserMemc,
 20+ $wgMessageCache, $wgUseDatabaseMessages, $wgMsgCacheExpiry,
2121 $wgNamespaceAliases, $wgNamespaceProtection, $wgLocalFileRepo,
2222 $wgThumbnailScriptPath, $wgScriptPath,
2323 $wgArticlePath, $wgStyleSheetPath, $wgScript, $wgStylePath;
Index: trunk/phase3/maintenance/tests/parser/parserTest.inc
@@ -120,9 +120,9 @@
121121 }
122122
123123 static function setUp() {
124 - global $wgParser, $wgParserConf, $IP, $messageMemc, $wgMemc, $wgDeferredUpdateList,
 124+ global $wgParser, $wgParserConf, $IP, $wgDeferredUpdateList,
125125 $wgUser, $wgLang, $wgOut, $wgRequest, $wgStyleDirectory, $wgEnableParserCache,
126 - $wgMessageCache, $wgUseDatabaseMessages, $wgMsgCacheExpiry, $parserMemc,
 126+ $wgMessageCache, $wgUseDatabaseMessages, $wgMsgCacheExpiry,
127127 $wgNamespaceAliases, $wgNamespaceProtection, $wgLocalFileRepo,
128128 $wgThumbnailScriptPath, $wgScriptPath,
129129 $wgArticlePath, $wgStyleSheetPath, $wgScript, $wgStylePath;
Index: trunk/phase3/maintenance/updateDoubleWidthSearch.php
@@ -39,9 +39,7 @@
4040 }
4141
4242 public function execute() {
43 - $quiet = $this->hasOption( 'q' );
4443 $maxLockTime = $this->getOption( 'l', 20 );
45 - $lockTime = time();
4644
4745 $dbw = wfGetDB( DB_MASTER );
4846 if ( $dbw->getType() !== 'mysql' ) {
Index: trunk/phase3/maintenance/reassignEdits.php
@@ -101,14 +101,17 @@
102102 if ( $total ) {
103103 # Reassign edits
104104 $this->output( "\nReassigning current edits..." );
105 - $res = $dbw->update( 'revision', $this->userSpecification( $to, 'rev_user', 'rev_user_text' ), $this->userConditions( $from, 'rev_user', 'rev_user_text' ), __METHOD__ );
 105+ $dbw->update( 'revision', $this->userSpecification( $to, 'rev_user', 'rev_user_text' ),
 106+ $this->userConditions( $from, 'rev_user', 'rev_user_text' ), __METHOD__ );
106107 $this->output( "done.\nReassigning deleted edits..." );
107 - $res = $dbw->update( 'archive', $this->userSpecification( $to, 'ar_user', 'ar_user_text' ), $this->userConditions( $from, 'ar_user', 'ar_user_text' ), __METHOD__ );
 108+ $dbw->update( 'archive', $this->userSpecification( $to, 'ar_user', 'ar_user_text' ),
 109+ $this->userConditions( $from, 'ar_user', 'ar_user_text' ), __METHOD__ );
108110 $this->output( "done.\n" );
109111 # Update recent changes if required
110112 if ( $rc ) {
111113 $this->output( "Updating recent changes..." );
112 - $dbw->update( 'recentchanges', $this->userSpecification( $to, 'rc_user', 'rc_user_text' ), $this->userConditions( $from, 'rc_user', 'rc_user_text' ), __METHOD__ );
 114+ $dbw->update( 'recentchanges', $this->userSpecification( $to, 'rc_user', 'rc_user_text' ),
 115+ $this->userConditions( $from, 'rc_user', 'rc_user_text' ), __METHOD__ );
113116 $this->output( "done.\n" );
114117 }
115118 }
Index: trunk/phase3/includes/parser/LinkHolderArray.php
@@ -158,7 +158,7 @@
159159 $query = false;
160160 $current = null;
161161 foreach ( $this->internals as $ns => $entries ) {
162 - foreach ( $entries as $index => $entry ) {
 162+ foreach ( $entries as $entry ) {
163163 $title = $entry['title'];
164164 $pdbk = $entry['pdbk'];
165165
Index: trunk/phase3/includes/db/DatabaseMysql.php
@@ -52,8 +52,6 @@
5353 $this->mPassword = $password;
5454 $this->mDBname = $dbName;
5555
56 - $success = false;
57 -
5856 wfProfileIn("dbconnect-$server");
5957
6058 # The kernel's default SYN retransmission period is far too slow for us,
Index: trunk/phase3/includes/db/LBFactory_Multi.php
@@ -87,7 +87,7 @@
8888 if ( $this->lastWiki === $wiki ) {
8989 return $this->lastSection;
9090 }
91 - list( $dbName, $prefix ) = $this->getDBNameAndPrefix( $wiki );
 91+ list( $dbName, ) = $this->getDBNameAndPrefix( $wiki );
9292 if ( isset( $this->sectionsByDB[$dbName] ) ) {
9393 $section = $this->sectionsByDB[$dbName];
9494 } else {
Index: trunk/phase3/includes/resourceloader/ResourceLoaderContext.php
@@ -43,7 +43,7 @@
4444 /* Methods */
4545
4646 public function __construct( ResourceLoader $resourceLoader, WebRequest $request ) {
47 - global $wgLang, $wgDefaultSkin, $wgResourceLoaderDebug;
 47+ global $wgDefaultSkin, $wgResourceLoaderDebug;
4848
4949 $this->resourceLoader = $resourceLoader;
5050 $this->request = $request;
Index: trunk/phase3/includes/StreamFile.php
@@ -96,7 +96,7 @@
9797 if ( $safe ) {
9898 global $wgFileBlacklist, $wgCheckFileExtensions, $wgStrictFileExtensions,
9999 $wgFileExtensions, $wgVerifyMimeType, $wgMimeTypeBlacklist;
100 - list( $partName, $extList ) = UploadBase::splitExtensions( $filename );
 100+ list( , $extList ) = UploadBase::splitExtensions( $filename );
101101 if ( UploadBase::checkFileExtensionList( $extList, $wgFileBlacklist ) ) {
102102 return 'unknown/unknown';
103103 }
Index: trunk/phase3/includes/specials/SpecialPrefixindex.php
@@ -128,7 +128,7 @@
129129 $namespace = NS_MAIN;
130130 } else {
131131 list( $namespace, $prefixKey, $prefix ) = $prefixList;
132 - list( /* $fromNs */, $fromKey, $from ) = $fromList;
 132+ list( , $fromKey, ) = $fromList;
133133
134134 ### FIXME: should complain if $fromNs != $namespace
135135
Index: trunk/phase3/includes/specials/SpecialUploadStash.php
@@ -57,9 +57,6 @@
5858 // prevent callers from doing standard HTML output -- we'll take it from here
5959 $wgOut->disable();
6060
61 - $code = 500;
62 - $message = 'Unknown error';
63 -
6461 if ( !isset( $subPage ) || $subPage === '' ) {
6562 // the user probably visited the page just to see what would happen, so explain it a bit.
6663 $code = '400';
@@ -126,7 +123,7 @@
127124 throw $e;
128125 }
129126
130 - list( $dummy, $width, $origKey ) = $matches;
 127+ list( , $width, $origKey ) = $matches;
131128
132129 // do not trap exceptions, if key is in bad format, or file not found,
133130 // let exceptions propagate to caller.
Index: trunk/phase3/includes/specials/SpecialBooksources.php
@@ -69,7 +69,6 @@
7070 public static function isValidISBN( $isbn ) {
7171 $isbn = self::cleanIsbn( $isbn );
7272 $sum = 0;
73 - $check = -1;
7473 if( strlen( $isbn ) == 13 ) {
7574 for( $i = 0; $i < 12; $i++ ) {
7675 if($i % 2 == 0) {

Follow-up revisions

RevisionCommit summaryAuthorDate
r77412Revert global removals in test/ from r77393reedy00:26, 29 November 2010
r77413Fix spaces to tabs from r77393reedy00:28, 29 November 2010
r77414Minor followup to r77393, change =&Method() to = &Method()reedy00:32, 29 November 2010
r77415Followup r77393, restore commented variable in SpecialPrefixindex as the vari...reedy00:41, 29 November 2010

Comments

#Comment by Platonides (talk | contribs)   23:58, 28 November 2010

More bugs of your IDE?

Problems in phase3/maintenance/tests/phpunit/suites/UploadFromUrlTestSuite.php:
 $wgMemc is used as local variable in line 46, function setUp
 $messageMemc is used as local variable in line 47, function setUp
 $parserMemc is used as local variable in line 48, function setUp
 $messageMemc is used as local variable in line 58, function setUp

Problems in trunk/phase3/maintenance/tests/parser/parserTest.inc:
 $wgMemc is used as local variable in line 152, function setUp
 $messageMemc is used as local variable in line 153, function setUp
 $parserMemc is used as local variable in line 154, function setUp
 $messageMemc is used as local variable in line 164, function setUp
#Comment by Reedy (talk | contribs)   00:30, 29 November 2010

Yes, seems so. Though, it sees "$blah = &something();" right, but not "$blah =& something();"

PHP shows it as "= &", so I will add spaces

http://www.php.net/manual/en/language.operators.assignment.php

Will report upstream though

#Comment by Reedy (talk | contribs)   00:39, 29 November 2010

Actually, it's all a bit weird. Cause they're globals, it shouldn't be whinging about it at all. Reported upstream anyway

#Comment by Platonides (talk | contribs)   00:03, 29 November 2010

- list( /* $fromNs */, $fromKey, $from ) = $fromList;

+			list( , $fromKey, ) = $fromList;

Keeping the unused vars commented there seems a good idea. Specially since the FIXME now has no sense.

Status & tagging log