r77495 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r77494‎ | r77495 | r77496 >
Date:18:44, 30 November 2010
Author:reedy
Status:ok (Comments)
Tags:
Comment:
More unused variables
Modified paths:
  • /trunk/phase3/includes/ConfEditor.php (modified) (history)
  • /trunk/phase3/includes/GlobalFunctions.php (modified) (history)
  • /trunk/phase3/includes/ImagePage.php (modified) (history)
  • /trunk/phase3/includes/MagicWord.php (modified) (history)
  • /trunk/phase3/includes/SiteConfiguration.php (modified) (history)
  • /trunk/phase3/includes/SquidPurgeClient.php (modified) (history)
  • /trunk/phase3/includes/StubObject.php (modified) (history)
  • /trunk/phase3/includes/Wiki.php (modified) (history)
  • /trunk/phase3/includes/db/DatabaseMysql.php (modified) (history)
  • /trunk/phase3/includes/db/LBFactory_Multi.php (modified) (history)
  • /trunk/phase3/includes/media/SVGMetadataExtractor.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialAllpages.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialLinkSearch.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialSearch.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialWatchlist.php (modified) (history)
  • /trunk/phase3/includes/upload/UploadBase.php (modified) (history)
  • /trunk/phase3/includes/upload/UploadStash.php (modified) (history)
  • /trunk/phase3/maintenance/fixSlaveDesync.php (modified) (history)
  • /trunk/phase3/maintenance/reassignEdits.php (modified) (history)
  • /trunk/phase3/maintenance/storage/checkStorage.php (modified) (history)
  • /trunk/phase3/maintenance/tests/parser/parserTest.inc (modified) (history)
  • /trunk/phase3/maintenance/tests/phpunit/includes/api/ApiUploadTest.php (modified) (history)
  • /trunk/phase3/maintenance/tests/phpunit/includes/api/RandomImageGenerator.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/storage/checkStorage.php
@@ -145,7 +145,7 @@
146146 $this->error( 'restore text', "Error: invalid URL \"{$row->old_text}\"", $row->old_id );
147147 continue;
148148 }
149 - list( $proto, $path ) = $urlParts;
 149+ list( $proto, ) = $urlParts;
150150 if ( $proto != 'DB' ) {
151151 $this->error( 'restore text', "Error: invalid external protocol \"$proto\"", $row->old_id );
152152 continue;
Index: trunk/phase3/maintenance/tests/phpunit/includes/api/RandomImageGenerator.php
@@ -204,12 +204,10 @@
205205
206206 $command = wfEscapeShellArg( $wgImageMagickConvertCommand ) . " " . implode( " ", $args );
207207 $retval = null;
208 - $output = wfShellExec( $command, $retval );
 208+ wfShellExec( $command, $retval );
209209 return ( $retval === 0 );
210210 }
211211
212 -
213 -
214212 /**
215213 * Generate a string of random colors for ImageMagick, like "rgb(12, 37, 98)"
216214 *
Index: trunk/phase3/maintenance/tests/phpunit/includes/api/ApiUploadTest.php
@@ -182,7 +182,7 @@
183183 'lgname' => $user->username,
184184 'lgpassword' => $user->password
185185 );
186 - list( $result, $request, $session ) = $this->doApiRequest( $params );
 186+ list( $result, , ) = $this->doApiRequest( $params );
187187 $this->assertArrayHasKey( "login", $result );
188188 $this->assertArrayHasKey( "result", $result['login'] );
189189 $this->assertEquals( "NeedToken", $result['login']['result'] );
@@ -194,7 +194,7 @@
195195 'lgname' => $user->username,
196196 'lgpassword' => $user->password
197197 );
198 - list( $result, $request, $session ) = $this->doApiRequest( $params );
 198+ list( $result, , $session ) = $this->doApiRequest( $params );
199199 $this->assertArrayHasKey( "login", $result );
200200 $this->assertArrayHasKey( "result", $result['login'] );
201201 $this->assertEquals( "Success", $result['login']['result'] );
@@ -280,7 +280,7 @@
281281
282282 $exception = false;
283283 try {
284 - list( $result, $request, $session ) = $this->doApiRequestWithToken( $params, $session );
 284+ list( $result, , ) = $this->doApiRequestWithToken( $params, $session );
285285 } catch ( UsageException $e ) {
286286 $exception = true;
287287 }
@@ -324,7 +324,7 @@
325325
326326 $exception = false;
327327 try {
328 - list( $result, $request, $session ) = $this->doApiRequestWithToken( $params, $session );
 328+ $this->doApiRequestWithToken( $params, $session );
329329 } catch ( UsageException $e ) {
330330 $this->assertContains( 'The file you submitted was empty', $e->getMessage() );
331331 $exception = true;
@@ -378,7 +378,7 @@
379379
380380 $exception = false;
381381 try {
382 - list( $result, $request, $session ) = $this->doApiRequestWithToken( $params, $session );
 382+ list( $result, , $session ) = $this->doApiRequestWithToken( $params, $session );
383383 } catch ( UsageException $e ) {
384384 $exception = true;
385385 }
@@ -394,7 +394,7 @@
395395
396396 $exception = false;
397397 try {
398 - list( $result, $request, $session ) = $this->doApiRequestWithToken( $params, $session );
 398+ list( $result, , ) = $this->doApiRequestWithToken( $params, $session );
399399 } catch ( UsageException $e ) {
400400 $exception = true;
401401 }
Index: trunk/phase3/maintenance/tests/parser/parserTest.inc
@@ -429,7 +429,6 @@
430430 $titleText = 'Parser test';
431431 }
432432
433 - $noxml = isset( $opts['noxml'] );
434433 $local = isset( $opts['local'] );
435434 $preprocessor = isset( $opts['preprocessor'] ) ? $opts['preprocessor'] : null;
436435 $parser = $this->getParser( $preprocessor );
Index: trunk/phase3/maintenance/reassignEdits.php
@@ -45,7 +45,7 @@
4646 if ( $to->getId() || $this->hasOption( 'force' ) ) {
4747 # Reassign the edits
4848 $report = $this->hasOption( 'report' );
49 - $count = $this->doReassignEdits( $from, $to, !$this->hasOption( 'norc' ), $report );
 49+ $this->doReassignEdits( $from, $to, !$this->hasOption( 'norc' ), $report );
5050 # If reporting, and there were items, advise the user to run without --report
5151 if ( $report ) {
5252 $this->output( "Run the script again without --report to update.\n" );
Index: trunk/phase3/maintenance/fixSlaveDesync.php
@@ -41,8 +41,6 @@
4242 if ( $this->hasArg() ) {
4343 $this->desyncFixPage( $this->getArg() );
4444 } else {
45 - $dbw = wfGetDB( DB_MASTER );
46 - $maxPage = $dbw->selectField( 'page', 'MAX(page_id)', false, __METHOD__ );
4745 $corrupt = $this->findPageLatestCorruption();
4846 foreach ( $corrupt as $id => $dummy ) {
4947 $this->desyncFixPage( $id );
Index: trunk/phase3/includes/upload/UploadBase.php
@@ -440,7 +440,6 @@
441441 $localFile = $this->getLocalFile();
442442 $filename = $localFile->getName();
443443 $n = strrpos( $filename, '.' );
444 - $partname = $n ? substr( $filename, 0, $n ) : $filename;
445444
446445 /**
447446 * Check whether the resulting filename is different from the desired one,
Index: trunk/phase3/includes/upload/UploadStash.php
@@ -303,7 +303,7 @@
304304 return null;
305305 }
306306 $extension = $this->getExtension();
307 - list( $thumbExt, $thumbMime ) = $this->handler->getThumbType( $extension, $this->getMimeType(), $params );
 307+ list( $thumbExt, ) = $this->handler->getThumbType( $extension, $this->getMimeType(), $params );
308308 $thumbName = $this->getHandler()->makeParamString( $params ) . '-' . $urlName;
309309 if ( $thumbExt != $extension ) {
310310 $thumbName .= ".$thumbExt";
Index: trunk/phase3/includes/GlobalFunctions.php
@@ -214,7 +214,7 @@
215215 } else {
216216 reset( $a );
217217 reset( $b );
218 - while( ( list( $keyA, $valueA ) = each( $a ) ) && ( list( $keyB, $valueB ) = each( $b ) ) ) {
 218+ while( ( list( , $valueA ) = each( $a ) ) && ( list( , $valueB ) = each( $b ) ) ) {
219219 $cmp = strcmp( $valueA, $valueB );
220220 if ( $cmp !== 0 ) {
221221 return $cmp;
Index: trunk/phase3/includes/StubObject.php
@@ -100,7 +100,7 @@
101101 throw new MWException( "Unstub loop detected on call of \${$this->mGlobal}->$name from $caller\n" );
102102 }
103103 wfDebug( "Unstubbing \${$this->mGlobal} on call of \${$this->mGlobal}::$name from $caller\n" );
104 - $obj = $GLOBALS[$this->mGlobal] = $this->_newObject();
 104+ $GLOBALS[$this->mGlobal] = $this->_newObject();
105105 --$recursionLevel;
106106 wfProfileOut( $fname );
107107 }
Index: trunk/phase3/includes/ImagePage.php
@@ -299,7 +299,6 @@
300300
301301 $this->loadFile();
302302
303 - $full_url = $this->displayImg->getURL();
304303 $sizeSel = intval( $wgUser->getOption( 'imagesize' ) );
305304 if ( !isset( $wgImageLimits[$sizeSel] ) ) {
306305 $sizeSel = User::getDefaultOption( 'imagesize' );
Index: trunk/phase3/includes/db/DatabaseMysql.php
@@ -90,7 +90,6 @@
9191 wfDebug( "DB connection error\n" );
9292 wfDebug( "Server: $server, User: $user, Password: " .
9393 substr( $password, 0, 3 ) . "..., error: " . mysql_error() . "\n" );
94 - $success = false;
9594 }
9695
9796 wfProfileOut("dbconnect-$server");
Index: trunk/phase3/includes/db/LBFactory_Multi.php
@@ -99,7 +99,7 @@
100100 }
101101
102102 function newMainLB( $wiki = false ) {
103 - list( $dbName, $prefix ) = $this->getDBNameAndPrefix( $wiki );
 103+ list( $dbName, ) = $this->getDBNameAndPrefix( $wiki );
104104 $section = $this->getSectionForWiki( $wiki );
105105 $groupLoads = array();
106106 if ( isset( $this->groupLoadsByDB[$dbName] ) ) {
Index: trunk/phase3/includes/SquidPurgeClient.php
@@ -265,7 +265,7 @@
266266 $this->markDown();
267267 return;
268268 }
269 - list( $all, $major, $minor, $status, $reason ) = $m;
 269+ list( , , , $status, $reason ) = $m;
270270 $status = intval( $status );
271271 if ( $status !== 200 && $status !== 404 ) {
272272 $this->log( "unexpected status code: $status $reason" );
@@ -356,12 +356,12 @@
357357 }
358358
359359 foreach ( $readSockets as $key => $socket ) {
360 - list( $clientIndex, $i ) = explode( '/', $key );
 360+ list( $clientIndex, ) = explode( '/', $key );
361361 $client = $this->clients[$clientIndex];
362362 $client->doReads();
363363 }
364364 foreach ( $writeSockets as $key => $socket ) {
365 - list( $clientIndex, $i ) = explode( '/', $key );
 365+ list( $clientIndex, ) = explode( '/', $key );
366366 $client = $this->clients[$clientIndex];
367367 $client->doWrites();
368368 }
Index: trunk/phase3/includes/media/SVGMetadataExtractor.php
@@ -130,7 +130,6 @@
131131 $keepReading = $this->reader->read();
132132 while( $keepReading ) {
133133 if( $this->reader->name == $name && $this->reader->nodeType == XmlReader::END_ELEMENT ) {
134 - $keepReading = false;
135134 break;
136135 } elseif( $this->reader->nodeType == XmlReader::TEXT ){
137136 $this->metadata[$metafield] = $this->reader->value;
@@ -169,9 +168,8 @@
170169 while( $keepReading ) {
171170 if( $this->reader->name == $name && $this->reader->depth <= $exitDepth
172171 && $this->reader->nodeType == XmlReader::END_ELEMENT ) {
173 - $keepReading = false;
174172 break;
175 - } elseif( $this->reader->nodeType == XmlReader::ELEMENT ){
 173+ } elseif ( $this->reader->nodeType == XmlReader::ELEMENT ) {
176174 switch( $this->reader->name ) {
177175 case 'animate':
178176 case 'set':
Index: trunk/phase3/includes/Wiki.php
@@ -108,7 +108,7 @@
109109 if( $wgRequest->getVal( 'printable' ) === 'yes' ) {
110110 $wgOut->setPrintable();
111111 }
112 - $ret = null;
 112+
113113 $curid = $wgRequest->getInt( 'curid' );
114114 if( $curid ) {
115115 // URLs like this are generated by RC, because rc_title isn't always accurate
Index: trunk/phase3/includes/MagicWord.php
@@ -720,7 +720,7 @@
721721 continue;
722722 }
723723 if ( preg_match( $regex, $text, $m ) ) {
724 - list( $id, $param ) = $this->parseMatch( $m );
 724+ list( $id, ) = $this->parseMatch( $m );
725725 if ( strlen( $m[0] ) >= strlen( $text ) ) {
726726 $text = '';
727727 } else {
Index: trunk/phase3/includes/ConfEditor.php
@@ -176,7 +176,7 @@
177177 // Has it got a comma already?
178178 if ( strpos( $lastEltPath, '@extra' ) === false && !$lastEltInfo['hasComma'] ) {
179179 // No comma, insert one after the value region
180 - list( $start, $end ) = $this->findValueRegion( $lastEltPath );
 180+ list( , $end ) = $this->findValueRegion( $lastEltPath );
181181 $this->replaceSourceRegion( $end - 1, $end - 1, ',' );
182182 }
183183
@@ -184,7 +184,7 @@
185185 list( $start, $end ) = $this->findDeletionRegion( $lastEltPath );
186186
187187 if ( $key === null ) {
188 - list( $indent, $arrowIndent ) = $this->getIndent( $start );
 188+ list( $indent, ) = $this->getIndent( $start );
189189 $textToInsert = "$indent$value,";
190190 } else {
191191 list( $indent, $arrowIndent ) =
@@ -202,12 +202,12 @@
203203 if ( $firstEltPath === false ) {
204204 throw new MWException( "Can't find array element of \"$path\"" );
205205 }
206 - list( $start, $end ) = $this->findDeletionRegion( $firstEltPath );
 206+ list( $start, ) = $this->findDeletionRegion( $firstEltPath );
207207 $info = $this->pathInfo[$firstEltPath];
208208
209209 // Make the text to insert
210210 if ( $key === null ) {
211 - list( $indent, $arrowIndent ) = $this->getIndent( $start );
 211+ list( $indent, ) = $this->getIndent( $start );
212212 $textToInsert = "$indent$value,";
213213 } else {
214214 list( $indent, $arrowIndent ) =
Index: trunk/phase3/includes/specials/SpecialAllpages.php
@@ -307,7 +307,7 @@
308308 $namespace = NS_MAIN;
309309 } else {
310310 list( $namespace, $fromKey, $from ) = $fromList;
311 - list( $namespace2, $toKey, $to ) = $toList;
 311+ list( , $toKey, $to ) = $toList;
312312
313313 $dbr = wfGetDB( DB_SLAVE );
314314 $conds = array(
Index: trunk/phase3/includes/specials/SpecialWatchlist.php
@@ -174,9 +174,7 @@
175175 # Possible where conditions
176176 $conds = array();
177177
178 - if( $days <= 0 ) {
179 - $andcutoff = '';
180 - } else {
 178+ if( $days > 0 ) {
181179 $conds[] = "rc_timestamp > '".$dbr->timestamp( time() - intval( $days * 86400 ) )."'";
182180 }
183181
Index: trunk/phase3/includes/specials/SpecialSearch.php
@@ -341,7 +341,6 @@
342342 protected function setupPage( $term ) {
343343 global $wgOut;
344344 // Figure out the active search profile header
345 - $nsAllSet = array_keys( SearchEngine::searchableNamespaces() );
346345 if( $this->searchAdvanced ) {
347346 $this->active = 'advanced';
348347 } else {
Index: trunk/phase3/includes/specials/SpecialLinkSearch.php
@@ -179,7 +179,7 @@
180180 */
181181 function doQuery( $offset, $limit, $shownavigation=true ) {
182182 global $wgOut;
183 - list( $this->mMungedQuery, $clause ) = LinkSearchPage::mungeQuery( $this->mQuery, $this->mProt );
 183+ list( $this->mMungedQuery, ) = LinkSearchPage::mungeQuery( $this->mQuery, $this->mProt );
184184 if( $this->mMungedQuery === false ) {
185185 $wgOut->addWikiMsg( 'linksearch-error' );
186186 } else {
Index: trunk/phase3/includes/SiteConfiguration.php
@@ -293,8 +293,9 @@
294294
295295 $ret = call_user_func_array( $this->siteParamsCallback, array( $this, $wiki ) );
296296 # Validate the returned value
297 - if( !is_array( $ret ) )
 297+ if( !is_array( $ret ) ) {
298298 return $default;
 299+ }
299300
300301 foreach( $default as $name => $def ){
301302 if( !isset( $ret[$name] ) || ( is_array( $default[$name] ) && !is_array( $ret[$name] ) ) )

Comments

#Comment by Catrope (talk | contribs)   15:44, 14 December 2010
-					list( $proto, $path ) = $urlParts;
+					list( $proto, ) = $urlParts;
[...]
-		list( $result, $request, $session ) = $this->doApiRequest( $params );
+		list( $result, , ) = $this->doApiRequest( $params );
[...]
-		list( $thumbExt, $thumbMime ) = $this->handler->getThumbType( $extension, $this->getMimeType(), $params );
+		list( $thumbExt, ) = $this->handler->getThumbType( $extension, $this->getMimeType(), $params );
[...]
-		list( $dbName, $prefix ) = $this->getDBNameAndPrefix( $wiki );
+		list( $dbName, ) = $this->getDBNameAndPrefix( $wiki );
[...]
-				list( $clientIndex, $i ) = explode( '/', $key );
+				list( $clientIndex, ) = explode( '/', $key );
[...]
-				list( $id, $param ) = $this->parseMatch( $m );
+				list( $id, ) = $this->parseMatch( $m );
[...]
-					list( $indent, $arrowIndent ) = $this->getIndent( $start );
+					list( $indent, ) = $this->getIndent( $start );
[...]
-				list( $start, $end ) = $this->findDeletionRegion( $firstEltPath );
+				list( $start, ) = $this->findDeletionRegion( $firstEltPath );
[...]
-		list( $this->mMungedQuery, $clause ) = LinkSearchPage::mungeQuery( $this->mQuery, $this->mProt );
+		list( $this->mMungedQuery,  ) = LinkSearchPage::mungeQuery( $this->mQuery, $this->mProt );

(The 2nd, 5th and 7th have multiple occurrences.) Kinda funky syntax there. To my surprise, this is legal.

Status & tagging log