From 10ecfeb03b223b22db1966c2967f2a405aa59723 Mon Sep 17 00:00:00 2001 From: Sam Reed Date: Wed, 10 Nov 2010 19:49:04 +0000 Subject: [PATCH] Various unused variables, add some braces Explicitally define some variables used in hook type calls --- includes/Article.php | 1 - includes/ChangesList.php | 2 +- includes/ConfEditor.php | 2 +- includes/EditPage.php | 4 +++- includes/HistoryPage.php | 4 +++- includes/ImagePage.php | 3 +-- includes/MimeMagic.php | 2 +- includes/OutputPage.php | 5 ----- includes/SkinTemplate.php | 1 - includes/Title.php | 1 - includes/WatchlistEditor.php | 3 ++- includes/db/DatabaseIbm_db2.php | 8 +++----- includes/db/DatabaseMssql.php | 4 ++-- includes/db/DatabasePostgres.php | 1 - includes/diff/WikiDiff.php | 4 ++-- includes/installer/DatabaseInstaller.php | 1 - includes/installer/MysqlInstaller.php | 2 +- includes/installer/MysqlUpdater.php | 2 +- includes/installer/OracleInstaller.php | 1 - includes/media/SVG.php | 1 - includes/parser/LinkHolderArray.php | 1 - includes/parser/Parser.php | 1 - includes/parser/Preprocessor_DOM.php | 12 +++++------- includes/specials/SpecialComparePages.php | 1 - includes/specials/SpecialSearch.php | 6 ++---- includes/specials/SpecialUserlogin.php | 3 +-- includes/upload/UploadBase.php | 2 +- maintenance/dumpTextPass.php | 1 - maintenance/orphans.php | 1 - maintenance/populateCategory.php | 1 - maintenance/reassignEdits.php | 2 +- .../tests/phpunit/includes/UploadFromUrlTest.php | 1 - .../tests/phpunit/includes/api/ApiUploadTest.php | 3 +-- .../phpunit/includes/api/RandomImageGenerator.php | 1 + 34 files changed, 33 insertions(+), 55 deletions(-) diff --git a/includes/Article.php b/includes/Article.php index 53abef098c..3d46f6b92e 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -1473,7 +1473,6 @@ class Article { global $wgOut; $oldid = $this->getOldID(); - $useParserCache = $this->useParserCache( $oldid ); $parserOptions = $this->getParserOptions(); # Render printable version, use printable version cache diff --git a/includes/ChangesList.php b/includes/ChangesList.php index a75ff2fcac..5de3b06d41 100644 --- a/includes/ChangesList.php +++ b/includes/ChangesList.php @@ -1055,7 +1055,7 @@ class EnhancedChangesList extends ChangesList { # Extract fields from DB into the function scope (rc_xxxx variables) // FIXME: Would be good to replace this extract() call with something // that explicitly initializes variables. - $classes = array(); // TODO implement + // TODO implement extract( $rcObj->mAttribs ); $query['curid'] = $rc_cur_id; diff --git a/includes/ConfEditor.php b/includes/ConfEditor.php index d62a9ceb1b..f240628e15 100644 --- a/includes/ConfEditor.php +++ b/includes/ConfEditor.php @@ -536,7 +536,7 @@ class ConfEditor { switch ( $state ) { case 'file': - $token = $this->expect( T_OPEN_TAG ); + $this->expect( T_OPEN_TAG ); $token = $this->skipSpace(); if ( $token->isEnd() ) { break 2; diff --git a/includes/EditPage.php b/includes/EditPage.php index 02b3c79bff..2f8fadf275 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -2229,7 +2229,9 @@ HTML $script = ''; foreach ( $toolarray as $tool ) { - if ( !$tool ) continue; + if ( !$tool ) { + continue; + } $params = array( $image = $wgStylePath . '/common/images/' . $tool['image'], diff --git a/includes/HistoryPage.php b/includes/HistoryPage.php index 42730ebfc7..ff1fc65532 100644 --- a/includes/HistoryPage.php +++ b/includes/HistoryPage.php @@ -529,7 +529,9 @@ class HistoryPager extends ReverseChronologicalPager { $rev->isDeleted( Revision::DELETED_RESTRICTED ), false ); } } - if( $del ) $s .= " $del "; + if( $del ) { + $s .= " $del "; + } $s .= " $link"; $s .= " " . diff --git a/includes/ImagePage.php b/includes/ImagePage.php index e1ffd8782e..d594c1e227 100644 --- a/includes/ImagePage.php +++ b/includes/ImagePage.php @@ -327,8 +327,6 @@ class ImagePage extends Article { $height_orig = $this->displayImg->getHeight( $page ); $height = $height_orig; - $showLink = false; - $linkAttribs = array( 'href' => $full_url ); $longDesc = $this->displayImg->getLongDesc(); wfRunHooks( 'ImageOpenShowImageInlineBefore', array( &$this, &$wgOut ) ); @@ -1002,6 +1000,7 @@ class ImageHistoryList { } $row .= ''; + $rowClass = null; wfRunHooks( 'ImagePageFileHistoryLine', array( $this, $file, &$row, &$rowClass ) ); $classAttr = $rowClass ? " class='$rowClass'" : ""; diff --git a/includes/MimeMagic.php b/includes/MimeMagic.php index 7d7fedd06a..16ff100bc5 100644 --- a/includes/MimeMagic.php +++ b/includes/MimeMagic.php @@ -826,7 +826,7 @@ class MimeMagic { $m = trim( $m ); $m = strtolower( $m ); - if ( strpos( $m, 'unknown' ) !== false ) { + if ( strpos( $m, 'unknown' ) === false ) { $m = null; } else { wfDebug( __METHOD__.": magic mime type of $file: $m\n" ); diff --git a/includes/OutputPage.php b/includes/OutputPage.php index f6c7a3fade..7aba700b1a 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -563,11 +563,6 @@ class OutputPage { $nameWithTags = Sanitizer::normalizeCharReferences( Sanitizer::removeHTMLtags( $name ) ); $this->mPagetitle = $nameWithTags; - $taction = $this->getPageTitleActionText(); - if( !empty( $taction ) ) { - $name .= ' - '.$taction; - } - # change "foo&bar" to "foo&bar" $this->setHTMLTitle( wfMsg( 'pagetitle', Sanitizer::stripAllTags( $nameWithTags ) ) ); } diff --git a/includes/SkinTemplate.php b/includes/SkinTemplate.php index 360918fbef..6728816d3c 100644 --- a/includes/SkinTemplate.php +++ b/includes/SkinTemplate.php @@ -358,7 +358,6 @@ class SkinTemplate extends Skin { if( $wgPageShowWatchingUsers ) { $dbr = wfGetDB( DB_SLAVE ); - $watchlist = $dbr->tableName( 'watchlist' ); $res = $dbr->select( 'watchlist', array( 'COUNT(*) AS n' ), array( 'wl_title' => $dbr->strencode( $this->mTitle->getDBkey() ), 'wl_namespace' => $this->mTitle->getNamespace() ), diff --git a/includes/Title.php b/includes/Title.php index 0909cfde6b..24e121264c 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -3302,7 +3302,6 @@ class Title { # Truncate for whole multibyte characters. +5 bytes for ellipsis $comment = $wgContLang->truncate( $comment, 250 ); - $newid = $nt->getArticleID(); $oldid = $this->getArticleID(); $latest = $this->getLatestRevId(); diff --git a/includes/WatchlistEditor.php b/includes/WatchlistEditor.php index 8850d26053..dda1b4a169 100644 --- a/includes/WatchlistEditor.php +++ b/includes/WatchlistEditor.php @@ -347,7 +347,8 @@ class WatchlistEditor { */ private function showNormalForm( $output, $user ) { global $wgUser; - if( ( $count = $this->showItemCount( $output, $user ) ) > 0 ) { + $count = $this->showItemCount( $output, $user ); + if( $count > 0 ) { $self = SpecialPage::getTitleFor( 'Watchlist' ); $form = Xml::openElement( 'form', array( 'method' => 'post', 'action' => $self->getLocalUrl( array( 'action' => 'edit' ) ) ) ); diff --git a/includes/db/DatabaseIbm_db2.php b/includes/db/DatabaseIbm_db2.php index 60a419055b..579581ca43 100644 --- a/includes/db/DatabaseIbm_db2.php +++ b/includes/db/DatabaseIbm_db2.php @@ -1249,11 +1249,9 @@ EOF; $join_conds ); // We must adjust for offset - if ( isset( $options['LIMIT'] ) ) { - if ( isset ( $options['OFFSET'] ) ) { - $limit = $options['LIMIT']; - $offset = $options['OFFSET']; - } + if ( isset( $options['LIMIT'] ) && isset ( $options['OFFSET'] ) ) { + $limit = $options['LIMIT']; + $offset = $options['OFFSET']; } // DB2 does not have a proper num_rows() function yet, so we must emulate diff --git a/includes/db/DatabaseMssql.php b/includes/db/DatabaseMssql.php index aceba9a7d4..943c070f1c 100644 --- a/includes/db/DatabaseMssql.php +++ b/includes/db/DatabaseMssql.php @@ -552,9 +552,9 @@ class DatabaseMssql extends DatabaseBase { */ function nextSequenceValue( $seqName ) { if ( !$this->tableExists( 'sequence_' . $seqName ) ) { - $ret = sqlsrv_query( $this->mConn, "CREATE TABLE [sequence_$seqName] (id INT NOT NULL IDENTITY PRIMARY KEY, junk varchar(10) NULL)" ); + sqlsrv_query( $this->mConn, "CREATE TABLE [sequence_$seqName] (id INT NOT NULL IDENTITY PRIMARY KEY, junk varchar(10) NULL)" ); } - $ret = sqlsrv_query( $this->mConn, "INSERT INTO [sequence_$seqName] (junk) VALUES ('')" ); + sqlsrv_query( $this->mConn, "INSERT INTO [sequence_$seqName] (junk) VALUES ('')" ); $ret = sqlsrv_query( $this->mConn, "SELECT TOP 1 id FROM [sequence_$seqName] ORDER BY id DESC" ); $row = sqlsrv_fetch_array( $ret, SQLSRV_FETCH_ASSOC );// KEEP ASSOC THERE, weird weird bug dealing with the return value if you don't diff --git a/includes/db/DatabasePostgres.php b/includes/db/DatabasePostgres.php index fe557d1db0..ec0e663ca1 100644 --- a/includes/db/DatabasePostgres.php +++ b/includes/db/DatabasePostgres.php @@ -751,7 +751,6 @@ class DatabasePostgres extends DatabaseBase { return true; } return false; - } /** diff --git a/includes/diff/WikiDiff.php b/includes/diff/WikiDiff.php index c148d23853..47605506d0 100644 --- a/includes/diff/WikiDiff.php +++ b/includes/diff/WikiDiff.php @@ -313,7 +313,7 @@ class _DiffEngine { } $matches = $ymatches[$line]; reset($matches); - while ( list( $junk, $y ) = each( $matches ) ) { + while ( list( , $y ) = each( $matches ) ) { if ( empty( $this->in_seq[$y] ) ) { $k = $this->_lcs_pos( $y ); assert( $k > 0 ); @@ -321,7 +321,7 @@ class _DiffEngine { break; } } - while (list ( /* $junk */, $y) = each($matches)) { + while (list ( , $y) = each($matches)) { if ($y > $this->seq[$k-1]) { assert($y < $this->seq[$k]); // Optimization: this is a common case: diff --git a/includes/installer/DatabaseInstaller.php b/includes/installer/DatabaseInstaller.php index 1bf498f34d..26cf53c316 100644 --- a/includes/installer/DatabaseInstaller.php +++ b/includes/installer/DatabaseInstaller.php @@ -395,7 +395,6 @@ abstract class DatabaseInstaller { * Set this to false to show a creation checkbox. */ public function getWebUserBox( $noCreateMsg = false ) { - $name = $this->getName(); $s = Html::openElement( 'fieldset' ) . Html::element( 'legend', array(), wfMsg( 'config-db-web-account' ) ) . $this->getCheckBox( diff --git a/includes/installer/MysqlInstaller.php b/includes/installer/MysqlInstaller.php index 12d02c544c..033875a298 100644 --- a/includes/installer/MysqlInstaller.php +++ b/includes/installer/MysqlInstaller.php @@ -366,7 +366,7 @@ class MysqlInstaller extends DatabaseInstaller { if ( !$create ) { // Test the web account try { - $webConn = new Database( + new Database( $this->getVar( 'wgDBserver' ), $this->getVar( 'wgDBuser' ), $this->getVar( 'wgDBpassword' ), diff --git a/includes/installer/MysqlUpdater.php b/includes/installer/MysqlUpdater.php index 1d187705f6..b8414dec13 100644 --- a/includes/installer/MysqlUpdater.php +++ b/includes/installer/MysqlUpdater.php @@ -355,7 +355,7 @@ class MysqlUpdater extends DatabaseUpdater { $prev_namespace = $row->cur_namespace; } $sql = "DELETE FROM $cur WHERE cur_id IN ( " . join( ',', $deleteId ) . ')'; - $rows = $this->db->query( $sql, __METHOD__ ); + $this->db->query( $sql, __METHOD__ ); $this->output( wfTimestamp( TS_DB ) ); $this->output( "......Deleted " . $this->db->affectedRows() . " records.\n" ); } diff --git a/includes/installer/OracleInstaller.php b/includes/installer/OracleInstaller.php index 8dbc7ad3e5..19c64e17d9 100644 --- a/includes/installer/OracleInstaller.php +++ b/includes/installer/OracleInstaller.php @@ -39,7 +39,6 @@ class OracleInstaller extends DatabaseInstaller { } public function getWebUserBox( $noCreateMsg = false ) { - $name = $this->getName(); $this->parent->setVar( '_SameAccount', false ); $this->parent->setVar( '_CreateDBAccount', true ); $this->parent->setVar( 'wgDBname', '' ); diff --git a/includes/media/SVG.php b/includes/media/SVG.php index 6c2d98059a..899429cc9e 100644 --- a/includes/media/SVG.php +++ b/includes/media/SVG.php @@ -150,7 +150,6 @@ class SvgHandler extends ImageHandler { } function getMetadata( $file, $filename ) { - $metadata = array(); try { $metadata = SVGMetadataExtractor::getMetadata( $filename ); } catch( Exception $e ) { diff --git a/includes/parser/LinkHolderArray.php b/includes/parser/LinkHolderArray.php index f879a65f09..d9ec72be83 100644 --- a/includes/parser/LinkHolderArray.php +++ b/includes/parser/LinkHolderArray.php @@ -159,7 +159,6 @@ class LinkHolderArray { $current = null; foreach ( $this->internals as $ns => $entries ) { foreach ( $entries as $index => $entry ) { - $key = "$ns:$index"; $title = $entry['title']; $pdbk = $entry['pdbk']; diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index c1ac704c0e..9e670f3668 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -789,7 +789,6 @@ class Parser { wfProfileIn( __METHOD__ ); $lines = StringUtils::explode( "\n", $text ); - $text = null; $out = ''; $td_history = array(); # Is currently a td tag open? $last_tag_history = array(); # Save history of last lag activated (td, th or caption) diff --git a/includes/parser/Preprocessor_DOM.php b/includes/parser/Preprocessor_DOM.php index 991f28cc42..2b635f7c0d 100644 --- a/includes/parser/Preprocessor_DOM.php +++ b/includes/parser/Preprocessor_DOM.php @@ -511,9 +511,7 @@ class Preprocessor_DOM implements Preprocessor { // another heading. Infinite loops are avoided because the next iteration MUST // hit the heading open case above, which unconditionally increments the // input pointer. - } - - elseif ( $found == 'open' ) { + } elseif ( $found == 'open' ) { # count opening brace characters $count = strspn( $text, $curChar, $i ); @@ -536,9 +534,7 @@ class Preprocessor_DOM implements Preprocessor { $accum .= htmlspecialchars( str_repeat( $curChar, $count ) ); } $i += $count; - } - - elseif ( $found == 'close' ) { + } elseif ( $found == 'close' ) { $piece = $stack->top; # lets check if there are enough characters for closing brace $maxCount = $piece->count; @@ -961,7 +957,9 @@ class PPFrame_DOM implements PPFrame { $iteratorStack[$level] = false; } - if ( $contextNode instanceof PPNode_DOM ) $contextNode = $contextNode->node; + if ( $contextNode instanceof PPNode_DOM ) { + $contextNode = $contextNode->node; + } $newIterator = false; diff --git a/includes/specials/SpecialComparePages.php b/includes/specials/SpecialComparePages.php index 8f7d024307..4650fc9458 100644 --- a/includes/specials/SpecialComparePages.php +++ b/includes/specials/SpecialComparePages.php @@ -97,7 +97,6 @@ class SpecialComparePages extends SpecialPage { $this->form(); if( $this->opts->getValue( 'rev1' ) && $this->opts->getValue( 'rev2' ) ) { - $title = Title::newFromText( $this->opts->getValue( 'page2' ) ); $de = new DifferenceEngine( null, $this->opts->getValue( 'rev1' ), $this->opts->getValue( 'rev2' ), diff --git a/includes/specials/SpecialSearch.php b/includes/specials/SpecialSearch.php index 1c1e1649d6..001b964be0 100644 --- a/includes/specials/SpecialSearch.php +++ b/includes/specials/SpecialSearch.php @@ -342,9 +342,9 @@ class SpecialSearch { global $wgOut; // Figure out the active search profile header $nsAllSet = array_keys( SearchEngine::searchableNamespaces() ); - if( $this->searchAdvanced ) + if( $this->searchAdvanced ) { $this->active = 'advanced'; - else { + } else { $profiles = $this->getSearchProfiles(); foreach( $profiles as $key => $data ) { @@ -416,7 +416,6 @@ class SpecialSearch { if( !is_null($infoLine) ) { $out .= "\n\n"; } - $off = $this->offset + 1; $out .= "