r76464 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r76463‎ | r76464 | r76465 >
Date:19:49, 10 November 2010
Author:reedy
Status:resolved
Tags:
Comment:
Various unused variables, add some braces

Explicitally define some variables used in hook type calls
Modified paths:
  • /trunk/phase3/includes/Article.php (modified) (history)
  • /trunk/phase3/includes/ChangesList.php (modified) (history)
  • /trunk/phase3/includes/ConfEditor.php (modified) (history)
  • /trunk/phase3/includes/EditPage.php (modified) (history)
  • /trunk/phase3/includes/HistoryPage.php (modified) (history)
  • /trunk/phase3/includes/ImagePage.php (modified) (history)
  • /trunk/phase3/includes/MimeMagic.php (modified) (history)
  • /trunk/phase3/includes/OutputPage.php (modified) (history)
  • /trunk/phase3/includes/SkinTemplate.php (modified) (history)
  • /trunk/phase3/includes/Title.php (modified) (history)
  • /trunk/phase3/includes/WatchlistEditor.php (modified) (history)
  • /trunk/phase3/includes/db/DatabaseIbm_db2.php (modified) (history)
  • /trunk/phase3/includes/db/DatabaseMssql.php (modified) (history)
  • /trunk/phase3/includes/db/DatabasePostgres.php (modified) (history)
  • /trunk/phase3/includes/diff/WikiDiff.php (modified) (history)
  • /trunk/phase3/includes/installer/DatabaseInstaller.php (modified) (history)
  • /trunk/phase3/includes/installer/MysqlInstaller.php (modified) (history)
  • /trunk/phase3/includes/installer/MysqlUpdater.php (modified) (history)
  • /trunk/phase3/includes/installer/OracleInstaller.php (modified) (history)
  • /trunk/phase3/includes/media/SVG.php (modified) (history)
  • /trunk/phase3/includes/parser/LinkHolderArray.php (modified) (history)
  • /trunk/phase3/includes/parser/Parser.php (modified) (history)
  • /trunk/phase3/includes/parser/Preprocessor_DOM.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialComparePages.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialSearch.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialUserlogin.php (modified) (history)
  • /trunk/phase3/includes/upload/UploadBase.php (modified) (history)
  • /trunk/phase3/maintenance/dumpTextPass.php (modified) (history)
  • /trunk/phase3/maintenance/orphans.php (modified) (history)
  • /trunk/phase3/maintenance/populateCategory.php (modified) (history)
  • /trunk/phase3/maintenance/reassignEdits.php (modified) (history)
  • /trunk/phase3/maintenance/tests/phpunit/includes/UploadFromUrlTest.php (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/tests/phpunit/includes/UploadFromUrlTest.php
@@ -133,7 +133,6 @@
134134 $this->assertTrue( $exception, "Got exception" );
135135
136136 self::$user->addGroup( 'sysop' );
137 - $exception = false;
138137 $data = $this->doApiRequest( array(
139138 'action' => 'upload',
140139 'url' => 'http://bits.wikimedia.org/skins-1.5/common/images/poweredby_mediawiki_88x31.png',
Index: trunk/phase3/maintenance/tests/phpunit/includes/api/RandomImageGenerator.php
@@ -203,6 +203,7 @@
204204 $args[] = $filename;
205205
206206 $command = wfEscapeShellArg( $wgImageMagickConvertCommand ) . " " . implode( " ", $args );
 207+ $retval = null;
207208 $output = wfShellExec( $command, $retval );
208209 return ( $retval === 0 );
209210 }
Index: trunk/phase3/maintenance/tests/phpunit/includes/api/ApiUploadTest.php
@@ -306,7 +306,6 @@
307307 global $wgUser;
308308 $wgUser = self::$users['uploader']->user;
309309
310 - $extension = 'png';
311310 $mimeType = 'image/png';
312311
313312 $filePath = tempnam( wfTempDir(), "" );
@@ -617,7 +616,7 @@
618617 $hash = File::sha1Base36( $filePath );
619618 $dupes = RepoGroup::singleton()->findBySha1( $hash );
620619 $success = true;
621 - foreach ( $dupes as $key => $dupe ) {
 620+ foreach ( $dupes as $dupe ) {
622621 $success &= $this->deleteFileByTitle( $dupe->getTitle() );
623622 }
624623 return $success;
Index: trunk/phase3/maintenance/populateCategory.php
@@ -66,7 +66,6 @@
6767
6868 $maxlag = intval( $maxlag );
6969 $throttle = intval( $throttle );
70 - $force = (bool)$force;
7170 if ( $begin !== '' ) {
7271 $where = 'cl_to > ' . $dbw->addQuotes( $begin );
7372 } else {
Index: trunk/phase3/maintenance/reassignEdits.php
@@ -108,7 +108,7 @@
109109 # Update recent changes if required
110110 if ( $rc ) {
111111 $this->output( "Updating recent changes..." );
112 - $res = $dbw->update( 'recentchanges', $this->userSpecification( $to, 'rc_user', 'rc_user_text' ), $this->userConditions( $from, 'rc_user', 'rc_user_text' ), __METHOD__ );
 112+ $dbw->update( 'recentchanges', $this->userSpecification( $to, 'rc_user', 'rc_user_text' ), $this->userConditions( $from, 'rc_user', 'rc_user_text' ), __METHOD__ );
113113 $this->output( "done.\n" );
114114 }
115115 }
Index: trunk/phase3/maintenance/orphans.php
@@ -165,7 +165,6 @@
166166 $dbw = wfGetDB( DB_MASTER );
167167 $page = $dbw->tableName( 'page' );
168168 $revision = $dbw->tableName( 'revision' );
169 - $text = $dbw->tableName( 'text' );
170169
171170 if ( $fix ) {
172171 $dbw->lockTables( $dbw, 'text', __METHOD__ );
Index: trunk/phase3/maintenance/dumpTextPass.php
@@ -263,7 +263,6 @@
264264 while ( true ) {
265265 try {
266266 $text = $this->getTextDb( $id );
267 - $ex = new MWException( "Graceful storage failure" );
268267 } catch ( DBQueryError $ex ) {
269268 $text = false;
270269 }
Index: trunk/phase3/includes/upload/UploadBase.php
@@ -340,7 +340,7 @@
341341 protected function verifyFile() {
342342 # get the title, even though we are doing nothing with it, because
343343 # we need to populate mFinalExtension
344 - $nt = $this->getTitle();
 344+ $this->getTitle();
345345
346346 $this->mFileProps = File::getPropsFromPath( $this->mTempPath, $this->mFinalExtension );
347347 $this->checkMacBinary();
Index: trunk/phase3/includes/diff/WikiDiff.php
@@ -313,7 +313,7 @@
314314 }
315315 $matches = $ymatches[$line];
316316 reset($matches);
317 - while ( list( $junk, $y ) = each( $matches ) ) {
 317+ while ( list( , $y ) = each( $matches ) ) {
318318 if ( empty( $this->in_seq[$y] ) ) {
319319 $k = $this->_lcs_pos( $y );
320320 assert( $k > 0 );
@@ -321,7 +321,7 @@
322322 break;
323323 }
324324 }
325 - while (list ( /* $junk */, $y) = each($matches)) {
 325+ while (list ( , $y) = each($matches)) {
326326 if ($y > $this->seq[$k-1]) {
327327 assert($y < $this->seq[$k]);
328328 // Optimization: this is a common case:
Index: trunk/phase3/includes/Article.php
@@ -1473,7 +1473,6 @@
14741474 global $wgOut;
14751475
14761476 $oldid = $this->getOldID();
1477 - $useParserCache = $this->useParserCache( $oldid );
14781477 $parserOptions = $this->getParserOptions();
14791478
14801479 # Render printable version, use printable version cache
Index: trunk/phase3/includes/MimeMagic.php
@@ -826,7 +826,7 @@
827827 $m = trim( $m );
828828 $m = strtolower( $m );
829829
830 - if ( strpos( $m, 'unknown' ) !== false ) {
 830+ if ( strpos( $m, 'unknown' ) === false ) {
831831 $m = null;
832832 } else {
833833 wfDebug( __METHOD__.": magic mime type of $file: $m\n" );
Index: trunk/phase3/includes/parser/LinkHolderArray.php
@@ -159,7 +159,6 @@
160160 $current = null;
161161 foreach ( $this->internals as $ns => $entries ) {
162162 foreach ( $entries as $index => $entry ) {
163 - $key = "$ns:$index";
164163 $title = $entry['title'];
165164 $pdbk = $entry['pdbk'];
166165
Index: trunk/phase3/includes/parser/Parser.php
@@ -789,7 +789,6 @@
790790 wfProfileIn( __METHOD__ );
791791
792792 $lines = StringUtils::explode( "\n", $text );
793 - $text = null;
794793 $out = '';
795794 $td_history = array(); # Is currently a td tag open?
796795 $last_tag_history = array(); # Save history of last lag activated (td, th or caption)
Index: trunk/phase3/includes/parser/Preprocessor_DOM.php
@@ -511,9 +511,7 @@
512512 // another heading. Infinite loops are avoided because the next iteration MUST
513513 // hit the heading open case above, which unconditionally increments the
514514 // input pointer.
515 - }
516 -
517 - elseif ( $found == 'open' ) {
 515+ } elseif ( $found == 'open' ) {
518516 # count opening brace characters
519517 $count = strspn( $text, $curChar, $i );
520518
@@ -536,9 +534,7 @@
537535 $accum .= htmlspecialchars( str_repeat( $curChar, $count ) );
538536 }
539537 $i += $count;
540 - }
541 -
542 - elseif ( $found == 'close' ) {
 538+ } elseif ( $found == 'close' ) {
543539 $piece = $stack->top;
544540 # lets check if there are enough characters for closing brace
545541 $maxCount = $piece->count;
@@ -961,7 +957,9 @@
962958 $iteratorStack[$level] = false;
963959 }
964960
965 - if ( $contextNode instanceof PPNode_DOM ) $contextNode = $contextNode->node;
 961+ if ( $contextNode instanceof PPNode_DOM ) {
 962+ $contextNode = $contextNode->node;
 963+ }
966964
967965 $newIterator = false;
968966
Index: trunk/phase3/includes/ImagePage.php
@@ -327,8 +327,6 @@
328328 $height_orig = $this->displayImg->getHeight( $page );
329329 $height = $height_orig;
330330
331 - $showLink = false;
332 - $linkAttribs = array( 'href' => $full_url );
333331 $longDesc = $this->displayImg->getLongDesc();
334332
335333 wfRunHooks( 'ImageOpenShowImageInlineBefore', array( &$this, &$wgOut ) );
@@ -1002,6 +1000,7 @@
10031001 }
10041002 $row .= '</td>';
10051003
 1004+ $rowClass = null;
10061005 wfRunHooks( 'ImagePageFileHistoryLine', array( $this, $file, &$row, &$rowClass ) );
10071006 $classAttr = $rowClass ? " class='$rowClass'" : "";
10081007
Index: trunk/phase3/includes/db/DatabasePostgres.php
@@ -751,7 +751,6 @@
752752 return true;
753753 }
754754 return false;
755 -
756755 }
757756
758757 /**
Index: trunk/phase3/includes/db/DatabaseIbm_db2.php
@@ -1249,11 +1249,9 @@
12501250 $join_conds );
12511251
12521252 // We must adjust for offset
1253 - if ( isset( $options['LIMIT'] ) ) {
1254 - if ( isset ( $options['OFFSET'] ) ) {
1255 - $limit = $options['LIMIT'];
1256 - $offset = $options['OFFSET'];
1257 - }
 1253+ if ( isset( $options['LIMIT'] ) && isset ( $options['OFFSET'] ) ) {
 1254+ $limit = $options['LIMIT'];
 1255+ $offset = $options['OFFSET'];
12581256 }
12591257
12601258 // DB2 does not have a proper num_rows() function yet, so we must emulate
Index: trunk/phase3/includes/db/DatabaseMssql.php
@@ -552,9 +552,9 @@
553553 */
554554 function nextSequenceValue( $seqName ) {
555555 if ( !$this->tableExists( 'sequence_' . $seqName ) ) {
556 - $ret = sqlsrv_query( $this->mConn, "CREATE TABLE [sequence_$seqName] (id INT NOT NULL IDENTITY PRIMARY KEY, junk varchar(10) NULL)" );
 556+ sqlsrv_query( $this->mConn, "CREATE TABLE [sequence_$seqName] (id INT NOT NULL IDENTITY PRIMARY KEY, junk varchar(10) NULL)" );
557557 }
558 - $ret = sqlsrv_query( $this->mConn, "INSERT INTO [sequence_$seqName] (junk) VALUES ('')" );
 558+ sqlsrv_query( $this->mConn, "INSERT INTO [sequence_$seqName] (junk) VALUES ('')" );
559559 $ret = sqlsrv_query( $this->mConn, "SELECT TOP 1 id FROM [sequence_$seqName] ORDER BY id DESC" );
560560 $row = sqlsrv_fetch_array( $ret, SQLSRV_FETCH_ASSOC );// KEEP ASSOC THERE, weird weird bug dealing with the return value if you don't
561561
Index: trunk/phase3/includes/WatchlistEditor.php
@@ -347,7 +347,8 @@
348348 */
349349 private function showNormalForm( $output, $user ) {
350350 global $wgUser;
351 - if( ( $count = $this->showItemCount( $output, $user ) ) > 0 ) {
 351+ $count = $this->showItemCount( $output, $user );
 352+ if( $count > 0 ) {
352353 $self = SpecialPage::getTitleFor( 'Watchlist' );
353354 $form = Xml::openElement( 'form', array( 'method' => 'post',
354355 'action' => $self->getLocalUrl( array( 'action' => 'edit' ) ) ) );
Index: trunk/phase3/includes/EditPage.php
@@ -2229,7 +2229,9 @@
22302230
22312231 $script = '';
22322232 foreach ( $toolarray as $tool ) {
2233 - if ( !$tool ) continue;
 2233+ if ( !$tool ) {
 2234+ continue;
 2235+ }
22342236
22352237 $params = array(
22362238 $image = $wgStylePath . '/common/images/' . $tool['image'],
Index: trunk/phase3/includes/OutputPage.php
@@ -563,11 +563,6 @@
564564 $nameWithTags = Sanitizer::normalizeCharReferences( Sanitizer::removeHTMLtags( $name ) );
565565 $this->mPagetitle = $nameWithTags;
566566
567 - $taction = $this->getPageTitleActionText();
568 - if( !empty( $taction ) ) {
569 - $name .= ' - '.$taction;
570 - }
571 -
572567 # change "<i>foo&amp;bar</i>" to "foo&bar"
573568 $this->setHTMLTitle( wfMsg( 'pagetitle', Sanitizer::stripAllTags( $nameWithTags ) ) );
574569 }
Index: trunk/phase3/includes/HistoryPage.php
@@ -529,7 +529,9 @@
530530 $rev->isDeleted( Revision::DELETED_RESTRICTED ), false );
531531 }
532532 }
533 - if( $del ) $s .= " $del ";
 533+ if( $del ) {
 534+ $s .= " $del ";
 535+ }
534536
535537 $s .= " $link";
536538 $s .= " <span class='history-user'>" .
Index: trunk/phase3/includes/installer/MysqlUpdater.php
@@ -355,7 +355,7 @@
356356 $prev_namespace = $row->cur_namespace;
357357 }
358358 $sql = "DELETE FROM $cur WHERE cur_id IN ( " . join( ',', $deleteId ) . ')';
359 - $rows = $this->db->query( $sql, __METHOD__ );
 359+ $this->db->query( $sql, __METHOD__ );
360360 $this->output( wfTimestamp( TS_DB ) );
361361 $this->output( "......<b>Deleted</b> " . $this->db->affectedRows() . " records.\n" );
362362 }
Index: trunk/phase3/includes/installer/DatabaseInstaller.php
@@ -395,7 +395,6 @@
396396 * Set this to false to show a creation checkbox.
397397 */
398398 public function getWebUserBox( $noCreateMsg = false ) {
399 - $name = $this->getName();
400399 $s = Html::openElement( 'fieldset' ) .
401400 Html::element( 'legend', array(), wfMsg( 'config-db-web-account' ) ) .
402401 $this->getCheckBox(
Index: trunk/phase3/includes/installer/MysqlInstaller.php
@@ -366,7 +366,7 @@
367367 if ( !$create ) {
368368 // Test the web account
369369 try {
370 - $webConn = new Database(
 370+ new Database(
371371 $this->getVar( 'wgDBserver' ),
372372 $this->getVar( 'wgDBuser' ),
373373 $this->getVar( 'wgDBpassword' ),
Index: trunk/phase3/includes/installer/OracleInstaller.php
@@ -39,7 +39,6 @@
4040 }
4141
4242 public function getWebUserBox( $noCreateMsg = false ) {
43 - $name = $this->getName();
4443 $this->parent->setVar( '_SameAccount', false );
4544 $this->parent->setVar( '_CreateDBAccount', true );
4645 $this->parent->setVar( 'wgDBname', '' );
Index: trunk/phase3/includes/media/SVG.php
@@ -150,7 +150,6 @@
151151 }
152152
153153 function getMetadata( $file, $filename ) {
154 - $metadata = array();
155154 try {
156155 $metadata = SVGMetadataExtractor::getMetadata( $filename );
157156 } catch( Exception $e ) {
Index: trunk/phase3/includes/ChangesList.php
@@ -1055,7 +1055,7 @@
10561056 # Extract fields from DB into the function scope (rc_xxxx variables)
10571057 // FIXME: Would be good to replace this extract() call with something
10581058 // that explicitly initializes variables.
1059 - $classes = array(); // TODO implement
 1059+ // TODO implement
10601060 extract( $rcObj->mAttribs );
10611061 $query['curid'] = $rc_cur_id;
10621062
Index: trunk/phase3/includes/Title.php
@@ -3302,7 +3302,6 @@
33033303 # Truncate for whole multibyte characters. +5 bytes for ellipsis
33043304 $comment = $wgContLang->truncate( $comment, 250 );
33053305
3306 - $newid = $nt->getArticleID();
33073306 $oldid = $this->getArticleID();
33083307 $latest = $this->getLatestRevId();
33093308
Index: trunk/phase3/includes/ConfEditor.php
@@ -536,7 +536,7 @@
537537
538538 switch ( $state ) {
539539 case 'file':
540 - $token = $this->expect( T_OPEN_TAG );
 540+ $this->expect( T_OPEN_TAG );
541541 $token = $this->skipSpace();
542542 if ( $token->isEnd() ) {
543543 break 2;
Index: trunk/phase3/includes/SkinTemplate.php
@@ -358,7 +358,6 @@
359359
360360 if( $wgPageShowWatchingUsers ) {
361361 $dbr = wfGetDB( DB_SLAVE );
362 - $watchlist = $dbr->tableName( 'watchlist' );
363362 $res = $dbr->select( 'watchlist',
364363 array( 'COUNT(*) AS n' ),
365364 array( 'wl_title' => $dbr->strencode( $this->mTitle->getDBkey() ), 'wl_namespace' => $this->mTitle->getNamespace() ),
Index: trunk/phase3/includes/specials/SpecialComparePages.php
@@ -97,7 +97,6 @@
9898 $this->form();
9999
100100 if( $this->opts->getValue( 'rev1' ) && $this->opts->getValue( 'rev2' ) ) {
101 - $title = Title::newFromText( $this->opts->getValue( 'page2' ) );
102101 $de = new DifferenceEngine( null,
103102 $this->opts->getValue( 'rev1' ),
104103 $this->opts->getValue( 'rev2' ),
Index: trunk/phase3/includes/specials/SpecialUserlogin.php
@@ -176,7 +176,6 @@
177177 $wgOut->addWikiMsg( 'accmailtext', $u->getName(), $u->getEmail() );
178178 $wgOut->returnToMain( false );
179179 }
180 - $u = 0;
181180 }
182181
183182 /**
@@ -620,7 +619,7 @@
621620 }
622621
623622 wfDebug( __METHOD__ . ": creating account\n" );
624 - $user = $this->initUser( $user, true );
 623+ $this->initUser( $user, true );
625624 return self::SUCCESS;
626625 }
627626
Index: trunk/phase3/includes/specials/SpecialSearch.php
@@ -342,9 +342,9 @@
343343 global $wgOut;
344344 // Figure out the active search profile header
345345 $nsAllSet = array_keys( SearchEngine::searchableNamespaces() );
346 - if( $this->searchAdvanced )
 346+ if( $this->searchAdvanced ) {
347347 $this->active = 'advanced';
348 - else {
 348+ } else {
349349 $profiles = $this->getSearchProfiles();
350350
351351 foreach( $profiles as $key => $data ) {
@@ -416,7 +416,6 @@
417417 if( !is_null($infoLine) ) {
418418 $out .= "\n<!-- {$infoLine} -->\n";
419419 }
420 - $off = $this->offset + 1;
421420 $out .= "<ul class='mw-search-results'>\n";
422421 while( $result = $matches->next() ) {
423422 $out .= $this->showHit( $result, $terms );
@@ -623,7 +622,6 @@
624623
625624 $out = "<div id='mw-search-interwiki'><div id='mw-search-interwiki-caption'>".
626625 wfMsg('search-interwiki-caption')."</div>\n";
627 - $off = $this->offset + 1;
628626 $out .= "<ul class='mw-search-iwresults'>\n";
629627
630628 // work out custom project captions

Follow-up revisions

RevisionCommit summaryAuthorDate
r77297revert r76464...hashar20:01, 25 November 2010

Status & tagging log