revert r76464
authorAntoine Musso <hashar@users.mediawiki.org>
Thu, 25 Nov 2010 20:01:34 +0000 (20:01 +0000)
committerAntoine Musso <hashar@users.mediawiki.org>
Thu, 25 Nov 2010 20:01:34 +0000 (20:01 +0000)
* mixed style changes and variable removing
* logic changes
* useful comments removed

34 files changed:
includes/Article.php
includes/ChangesList.php
includes/ConfEditor.php
includes/EditPage.php
includes/HistoryPage.php
includes/ImagePage.php
includes/MimeMagic.php
includes/OutputPage.php
includes/SkinTemplate.php
includes/Title.php
includes/WatchlistEditor.php
includes/db/DatabaseIbm_db2.php
includes/db/DatabaseMssql.php
includes/db/DatabasePostgres.php
includes/diff/WikiDiff.php
includes/installer/DatabaseInstaller.php
includes/installer/MysqlInstaller.php
includes/installer/MysqlUpdater.php
includes/installer/OracleInstaller.php
includes/media/SVG.php
includes/parser/LinkHolderArray.php
includes/parser/Parser.php
includes/parser/Preprocessor_DOM.php
includes/specials/SpecialComparePages.php
includes/specials/SpecialSearch.php
includes/specials/SpecialUserlogin.php
includes/upload/UploadBase.php
maintenance/dumpTextPass.php
maintenance/orphans.php
maintenance/populateCategory.php
maintenance/reassignEdits.php
maintenance/tests/phpunit/includes/UploadFromUrlTest.php
maintenance/tests/phpunit/includes/api/ApiUploadTest.php
maintenance/tests/phpunit/includes/api/RandomImageGenerator.php

index 7a99bef..f82b141 100644 (file)
@@ -1473,6 +1473,7 @@ class Article {
                global $wgOut;
 
                $oldid = $this->getOldID();
+               $useParserCache = $this->useParserCache( $oldid );
                $parserOptions = $this->getParserOptions();
 
                # Render printable version, use printable version cache
index 5de3b06..a75ff2f 100644 (file)
@@ -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.
-               // TODO implement
+               $classes = array(); // TODO implement
                extract( $rcObj->mAttribs );
                $query['curid'] = $rc_cur_id;
 
index f240628..d62a9ce 100644 (file)
@@ -536,7 +536,7 @@ class ConfEditor {
 
                        switch ( $state ) {
                        case 'file':
-                               $this->expect( T_OPEN_TAG );
+                               $token = $this->expect( T_OPEN_TAG );
                                $token = $this->skipSpace();
                                if ( $token->isEnd() ) {
                                        break 2;
index 1182ef7..b878c6d 100644 (file)
@@ -2232,9 +2232,7 @@ HTML
 
                $script = '';
                foreach ( $toolarray as $tool ) {
-                       if ( !$tool ) {
-                               continue;
-                       }
+                       if ( !$tool ) continue;
 
                        $params = array(
                                $image = $wgStylePath . '/common/images/' . $tool['image'],
index 88a8ee4..d45d08c 100644 (file)
@@ -538,9 +538,7 @@ class HistoryPager extends ReverseChronologicalPager {
                                        $rev->isDeleted( Revision::DELETED_RESTRICTED ), false );
                        }
                }
-               if ( $del ) {
-                       $s .= " $del ";
-               }
+               if( $del ) $s .= " $del ";
 
                $s .= " $link";
                $s .= " <span class='history-user'>" .
index a1b204f..24999eb 100644 (file)
@@ -331,6 +331,8 @@ 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 ) );
@@ -1009,7 +1011,6 @@ class ImageHistoryList {
                }
                $row .= '</td>';
 
-               $rowClass = null;
                wfRunHooks( 'ImagePageFileHistoryLine', array( $this, $file, &$row, &$rowClass ) );
                $classAttr = $rowClass ? " class='$rowClass'" : "";
 
index 16ff100..7d7fedd 100644 (file)
@@ -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" );
index a80d4eb..3740952 100644 (file)
@@ -563,6 +563,11 @@ class OutputPage {
                $nameWithTags = Sanitizer::normalizeCharReferences( Sanitizer::removeHTMLtags( $name ) );
                $this->mPagetitle = $nameWithTags;
 
+               $taction = $this->getPageTitleActionText();
+               if( !empty( $taction ) ) {
+                       $name .= ' - '.$taction;
+               }
+
                # change "<i>foo&amp;bar</i>" to "foo&bar"
                $this->setHTMLTitle( wfMsg( 'pagetitle', Sanitizer::stripAllTags( $nameWithTags ) ) );
        }
index 1a713fd..bd794c7 100644 (file)
@@ -358,6 +358,7 @@ 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() ),
index 13ea7d9..5b90cfe 100644 (file)
@@ -3302,6 +3302,7 @@ 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();
 
index dda1b4a..8850d26 100644 (file)
@@ -347,8 +347,7 @@ class WatchlistEditor {
         */
        private function showNormalForm( $output, $user ) {
                global $wgUser;
-               $count = $this->showItemCount( $output, $user );
-               if( $count > 0 ) {
+               if( ( $count = $this->showItemCount( $output, $user ) ) > 0 ) {
                        $self = SpecialPage::getTitleFor( 'Watchlist' );
                        $form  = Xml::openElement( 'form', array( 'method' => 'post',
                                'action' => $self->getLocalUrl( array( 'action' => 'edit' ) ) ) );
index a3a6829..5d79586 100644 (file)
@@ -1249,9 +1249,11 @@ EOF;
                        $join_conds );
 
                // We must adjust for offset
-               if ( isset( $options['LIMIT'] ) && isset ( $options['OFFSET'] ) ) {
-                       $limit = $options['LIMIT'];
-                       $offset = $options['OFFSET'];
+               if ( isset( $options['LIMIT'] ) ) {
+                       if ( isset ( $options['OFFSET'] ) ) {
+                               $limit = $options['LIMIT'];
+                               $offset = $options['OFFSET'];
+                       }
                }
 
                // DB2 does not have a proper num_rows() function yet, so we must emulate
index 93c1cf2..a1b0a30 100644 (file)
@@ -552,9 +552,9 @@ class DatabaseMssql extends DatabaseBase {
         */
        function nextSequenceValue( $seqName ) {
                if ( !$this->tableExists( 'sequence_' . $seqName ) ) {
-                       sqlsrv_query( $this->mConn, "CREATE TABLE [sequence_$seqName] (id INT NOT NULL IDENTITY PRIMARY KEY, junk varchar(10) NULL)" );
+                       $ret = sqlsrv_query( $this->mConn, "CREATE TABLE [sequence_$seqName] (id INT NOT NULL IDENTITY PRIMARY KEY, junk varchar(10) NULL)" );
                }
-               sqlsrv_query( $this->mConn, "INSERT INTO [sequence_$seqName] (junk) VALUES ('')" );
+               $ret = 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
 
index ecf67de..79816c2 100644 (file)
@@ -751,6 +751,7 @@ class DatabasePostgres extends DatabaseBase {
                        return true;
                }
                return false;
+
        }
 
        /**
index 4760550..c148d23 100644 (file)
@@ -313,7 +313,7 @@ class _DiffEngine {
                                }
                                $matches = $ymatches[$line];
                                reset($matches);
-                               while ( list( , $y ) = each( $matches ) ) {
+                               while ( list( $junk, $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 ( , $y) = each($matches)) {
+                               while (list ( /* $junk */, $y) = each($matches)) {
                                        if ($y > $this->seq[$k-1]) {
                                                assert($y < $this->seq[$k]);
                                                // Optimization: this is a common case:
index 26cf53c..1bf498f 100644 (file)
@@ -395,6 +395,7 @@ 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(
index 033875a..12d02c5 100644 (file)
@@ -366,7 +366,7 @@ class MysqlInstaller extends DatabaseInstaller {
                if ( !$create ) {
                        // Test the web account
                        try {
-                               new Database(
+                               $webConn = new Database(
                                        $this->getVar( 'wgDBserver' ),
                                        $this->getVar( 'wgDBuser' ),
                                        $this->getVar( 'wgDBpassword' ),
index 50376a5..911a7d2 100644 (file)
@@ -355,7 +355,7 @@ class MysqlUpdater extends DatabaseUpdater {
                                $prev_namespace = $row->cur_namespace;
                        }
                        $sql = "DELETE FROM $cur WHERE cur_id IN ( " . join( ',', $deleteId ) . ')';
-                       $this->db->query( $sql, __METHOD__ );
+                       $rows = $this->db->query( $sql, __METHOD__ );
                        $this->output( wfTimestamp( TS_DB ) );
                        $this->output( "......<b>Deleted</b> " . $this->db->affectedRows() . " records.\n" );
                }
index 19c64e1..8dbc7ad 100644 (file)
@@ -39,6 +39,7 @@ 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', '' );
index 899429c..6c2d980 100644 (file)
@@ -150,6 +150,7 @@ class SvgHandler extends ImageHandler {
        }
 
        function getMetadata( $file, $filename ) {
+               $metadata = array();
                try {
                        $metadata = SVGMetadataExtractor::getMetadata( $filename );
                } catch( Exception $e ) {
index d9ec72b..f879a65 100644 (file)
@@ -159,6 +159,7 @@ class LinkHolderArray {
                $current = null;
                foreach ( $this->internals as $ns => $entries ) {
                        foreach ( $entries as $index => $entry ) {
+                               $key = "$ns:$index";
                                $title = $entry['title'];
                                $pdbk = $entry['pdbk'];
 
index ae5e891..336bdea 100644 (file)
@@ -789,6 +789,7 @@ 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)
index 2b635f7..991f28c 100644 (file)
@@ -511,7 +511,9 @@ 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 );
 
@@ -534,7 +536,9 @@ 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;
@@ -957,9 +961,7 @@ 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;
 
index 4650fc9..8f7d024 100644 (file)
@@ -97,6 +97,7 @@ 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' ),
index 2a0c9ef..b922c6f 100644 (file)
@@ -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,6 +416,7 @@ class SpecialSearch {
                if( !is_null($infoLine) ) {
                        $out .= "\n<!-- {$infoLine} -->\n";
                }
+               $off = $this->offset + 1;
                $out .= "<ul class='mw-search-results'>\n";
                while( $result = $matches->next() ) {
                        $out .= $this->showHit( $result, $terms );
@@ -622,6 +623,7 @@ class SpecialSearch {
 
                $out = "<div id='mw-search-interwiki'><div id='mw-search-interwiki-caption'>".
                        wfMsg('search-interwiki-caption')."</div>\n";
+               $off = $this->offset + 1;
                $out .= "<ul class='mw-search-iwresults'>\n";
 
                // work out custom project captions
index 6c3929a..254f27b 100644 (file)
@@ -176,6 +176,7 @@ class LoginForm {
                        $wgOut->addWikiMsg( 'accmailtext', $u->getName(), $u->getEmail() );
                        $wgOut->returnToMain( false );
                }
+               $u = 0;
        }
 
        /**
@@ -619,7 +620,7 @@ class LoginForm {
                }
 
                wfDebug( __METHOD__ . ": creating account\n" );
-               $this->initUser( $user, true );
+               $user = $this->initUser( $user, true );
                return self::SUCCESS;
        }
 
index 5c970d8..e6334ff 100644 (file)
@@ -340,7 +340,7 @@ abstract class UploadBase {
        protected function verifyFile() {
                # get the title, even though we are doing nothing with it, because
                # we need to populate mFinalExtension 
-               $this->getTitle();
+               $nt = $this->getTitle();
                
                $this->mFileProps = File::getPropsFromPath( $this->mTempPath, $this->mFinalExtension );
                $this->checkMacBinary();
index 3a06cce..c95d1ff 100644 (file)
@@ -263,6 +263,7 @@ class TextPassDumper extends BackupDumper {
                while ( true ) {
                        try {
                                $text = $this->getTextDb( $id );
+                               $ex = new MWException( "Graceful storage failure" );
                        } catch ( DBQueryError $ex ) {
                                $text = false;
                        }
index 7294080..4a9a650 100644 (file)
@@ -165,6 +165,7 @@ class Orphans extends Maintenance {
                $dbw = wfGetDB( DB_MASTER );
                $page     = $dbw->tableName( 'page' );
                $revision = $dbw->tableName( 'revision' );
+               $text     = $dbw->tableName( 'text' );
        
                if ( $fix ) {
                        $dbw->lockTables( $dbw, 'text', __METHOD__ );
index 3b3101a..30cea73 100644 (file)
@@ -66,6 +66,7 @@ TEXT;
        
                $maxlag = intval( $maxlag );
                $throttle = intval( $throttle );
+               $force = (bool)$force;
                if ( $begin !== '' ) {
                        $where = 'cl_to > ' . $dbw->addQuotes( $begin );
                } else {
index 721605c..e59c654 100644 (file)
@@ -108,7 +108,7 @@ class ReassignEdits extends Maintenance {
                                # Update recent changes if required
                                if ( $rc ) {
                                        $this->output( "Updating recent changes..." );
-                                       $dbw->update( 'recentchanges', $this->userSpecification( $to, 'rc_user', 'rc_user_text' ), $this->userConditions( $from, 'rc_user', 'rc_user_text' ), __METHOD__ );
+                                       $res = $dbw->update( 'recentchanges', $this->userSpecification( $to, 'rc_user', 'rc_user_text' ), $this->userConditions( $from, 'rc_user', 'rc_user_text' ), __METHOD__ );
                                        $this->output( "done.\n" );
                                }
                        }
index 6c4a410..32678d6 100644 (file)
@@ -133,6 +133,7 @@ class UploadFromUrlTest extends ApiTestSetup {
                $this->assertTrue( $exception, "Got exception" );
 
                self::$user->addGroup( 'sysop' );
+               $exception = false;
                $data = $this->doApiRequest( array(
                        'action' => 'upload',
                        'url' => 'http://bits.wikimedia.org/skins-1.5/common/images/poweredby_mediawiki_88x31.png',
index f213dcc..9635c47 100644 (file)
@@ -303,6 +303,7 @@ class ApiUploadTest extends ApiTestCase {
                global $wgUser;
                $wgUser = self::$users['uploader']->user;
 
+               $extension = 'png';
                $mimeType = 'image/png';
 
                $filePath = tempnam( wfTempDir(), "" );
@@ -616,7 +617,7 @@ class ApiUploadTest extends ApiTestCase {
                $hash = File::sha1Base36( $filePath );
                $dupes = RepoGroup::singleton()->findBySha1( $hash );
                $success = true;
-               foreach ( $dupes as $dupe ) {
+               foreach ( $dupes as $key => $dupe ) {
                        $success &= $this->deleteFileByTitle( $dupe->getTitle() );
                }
                return $success;
index f544a71..8602196 100644 (file)
@@ -203,7 +203,6 @@ class RandomImageGenerator {
                $args[] = $filename;
 
                $command = wfEscapeShellArg( $wgImageMagickConvertCommand ) . " " . implode( " ", $args );
-               $retval = null;
                $output = wfShellExec( $command, $retval );
                return ( $retval === 0 );
        }