For the "includes/" directory:
authorNick Jenkins <nickj@users.mediawiki.org>
Fri, 12 Jan 2007 10:03:51 +0000 (10:03 +0000)
committerNick Jenkins <nickj@users.mediawiki.org>
Fri, 12 Jan 2007 10:03:51 +0000 (10:03 +0000)
* removing unused local vars
* removing used global declarations
* adding FIXMEs against extract() calls and lines that seem to be using uninitialized variables
* adding some array() declarations.

19 files changed:
includes/Article.php
includes/BagOStuff.php
includes/ChangesList.php
includes/Database.php
includes/DifferenceEngine.php
includes/DjVuImage.php
includes/IP.php
includes/ImagePage.php
includes/LogPage.php
includes/MessageCache.php
includes/MimeMagic.php
includes/RecentChange.php
includes/Skin.php
includes/SkinTemplate.php
includes/SpecialPreferences.php
includes/SpecialPrefixindex.php
includes/SpecialUpload.php
includes/SpecialVersion.php
includes/SpecialWatchlist.php

index c4c6b1f..6ca7dad 100644 (file)
@@ -407,8 +407,7 @@ class Article {
         * @return Database
         */
        function &getDB() {
-               $ret =& wfGetDB( DB_MASTER );
-               return $ret;
+               return wfGetDB( DB_MASTER );
        }
 
        /**
@@ -1674,7 +1673,7 @@ class Article {
                                if( $protect )
                                        $comment .= " [$updated]";
                                $nullRevision = Revision::newNullRevision( $dbw, $id, $comment, true );
-                               $nullRevId = $nullRevision->insertOn( $dbw );
+                               $nullRevision->insertOn( $dbw );
 
                                # Update restrictions table
                                foreach( $limit as $action => $restrictions ) {
@@ -2833,7 +2832,6 @@ class Article {
                if ( !wfReadOnly() ) {
 
                        # Get templates from templatelinks
-                       $result = array();
                        $id = $this->mTitle->getArticleID();
 
                        $tlTemplates = array();
index c720807..ab05ab2 100644 (file)
@@ -413,7 +413,6 @@ class MediaWikiBagOStuff extends SqlBagOStuff {
                return $dbw->lastError();
        }
        function _maxdatetime() {
-               $dbw =& wfGetDB(DB_MASTER);
                if ( time() > 0x7fffffff ) {
                        return $this->_fromunixtime( 1<<62 );
                } else {
index 58c01ed..a8d3ba8 100644 (file)
@@ -229,6 +229,7 @@ class OldChangesList extends ChangesList {
                wfProfileIn( $fname );
 
                # Extract DB fields into local scope
+               // FIXME: Would be good to replace this extract() call with something that explicitly initializes local variables.
                extract( $rc->mAttribs );
 
                # Should patrol-related stuff be shown?
@@ -301,6 +302,7 @@ class EnhancedChangesList extends ChangesList {
                $rc = RCCacheEntry::newFromParent( $baseRC );
 
                # 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 local variables.
                extract( $rc->mAttribs );
                $curIdEq = 'curid=' . $rc_cur_id;
 
@@ -506,6 +508,7 @@ class EnhancedChangesList extends ChangesList {
                $r .= '<div id="'.$rci.'" style="display:none">';
                foreach( $block as $rcObj ) {
                        # Get rc_xxxx variables
+                       // FIXME: Would be good to replace this extract() call with something that explicitly initializes local variables.
                        extract( $rcObj->mAttribs );
 
                        $r .= $this->spacerArrow();
@@ -609,6 +612,7 @@ class EnhancedChangesList extends ChangesList {
                global $wgContLang, $wgRCShowChangedSize;
 
                # Get rc_xxxx variables
+               // FIXME: Would be good to replace this extract() call with something that explicitly initializes local variables.
                extract( $rcObj->mAttribs );
                $curIdEq = 'curid='.$rc_cur_id;
 
index eb1ee13..0bb0279 100644 (file)
@@ -154,6 +154,7 @@ border=\"0\" ALT=\"Google\"></A>
 
                        $cache = new HTMLFileCache( $t );
                        if( $cache->isFileCached() ) {
+                               // FIXME: $msg is not defined on the next line.
                                $msg = '<p style="color: red"><b>'.$msg."<br />\n" .
                                        $cachederror . "</b></p>\n";
 
index 4563e6b..6052323 100644 (file)
@@ -64,7 +64,7 @@ class DifferenceEngine {
        }
 
        function showDiffPage( $diffOnly = false ) {
-               global $wgUser, $wgOut, $wgContLang, $wgUseExternalEditor, $wgUseRCPatrol;
+               global $wgUser, $wgOut, $wgUseExternalEditor, $wgUseRCPatrol;
                $fname = 'DifferenceEngine::showDiffPage';
                wfProfileIn( $fname );
 
index f7297dc..ceb7aa1 100644 (file)
@@ -68,6 +68,7 @@ class DjVuImage {
        function dump() {
                $file = fopen( $this->mFilename, 'rb' );
                $header = fread( $file, 12 );
+               // FIXME: Would be good to replace this extract() call with something that explicitly initializes local variables.
                extract( unpack( 'a4magic/a4chunk/NchunkLength', $header ) );
                echo "$chunk $chunkLength\n";
                $this->dumpForm( $file, $chunkLength, 1 );
@@ -83,6 +84,7 @@ class DjVuImage {
                        if( $chunkHeader == '' ) {
                                break;
                        }
+                       // FIXME: Would be good to replace this extract() call with something that explicitly initializes local variables.
                        extract( unpack( 'a4chunk/NchunkLength', $chunkHeader ) );
                        echo str_repeat( ' ', $indent * 4 ) . "$chunk $chunkLength\n";
                        
@@ -111,6 +113,7 @@ class DjVuImage {
                if( strlen( $header ) < 16 ) {
                        wfDebug( __METHOD__ . ": too short file header\n" );
                } else {
+                       // FIXME: Would be good to replace this extract() call with something that explicitly initializes local variables.
                        extract( unpack( 'a4magic/a4form/NformLength/a4subtype', $header ) );
                        
                        if( $magic != 'AT&T' ) {
@@ -134,6 +137,7 @@ class DjVuImage {
                if( strlen( $header ) < 8 ) {
                        return array( false, 0 );
                } else {
+                       // FIXME: Would be good to replace this extract() call with something that explicitly initializes local variables.
                        extract( unpack( 'a4chunk/Nlength', $header ) );
                        return array( $chunk, $length );
                }
@@ -192,6 +196,7 @@ class DjVuImage {
                        return false;
                }
                
+               // FIXME: Would be good to replace this extract() call with something that explicitly initializes local variables.
                extract( unpack(
                        'nwidth/' .
                        'nheight/' .
index edf4af7..efa6bfd 100644 (file)
@@ -244,6 +244,7 @@ class IP {
            return $addr;
 
        // IPv6 loopback address
+       $m = array();
        if ( preg_match( '/^0*' . RE_IPV6_GAP . '1$/', $addr, $m ) )
            return '127.0.0.1';
 
index 43b9913..4503c4a 100644 (file)
@@ -645,9 +645,6 @@ END
                }
                $oldver = wfTimestampNow() . "!{$name}";
 
-               $dbr =& wfGetDB( DB_SLAVE );
-               $size = $dbr->selectField( 'oldimage', 'oi_size', array( 'oi_archive_name' => $oldimage )  );
-
                if ( ! rename( $curfile, "${archive}/{$oldver}" ) ) {
                        $wgOut->showFileRenameError( $curfile, "${archive}/{$oldver}" );
                        return;
index 4e50483..a0b45e7 100644 (file)
@@ -253,7 +253,6 @@ class LogPage {
         * @return string
         */
        public static function formatBlockFlags( $flags ) {
-               static $messages = false;
                $flags = explode( ',', trim( $flags ) );
                if( count( $flags ) > 0 ) {
                        for( $i = 0; $i < count( $flags ); $i++ )
index a269c62..0b5b7e6 100644 (file)
@@ -298,7 +298,7 @@ class MessageCache {
         * Loads all or main part of cacheable messages from the database
         */
        function loadFromDB() {
-               global $wgLang, $wgMaxMsgCacheEntrySize;
+               global $wgMaxMsgCacheEntrySize;
 
                wfProfileIn( __METHOD__ );
                $dbr =& wfGetDB( DB_SLAVE );
index 9fc0bf7..c7de6ed 100644 (file)
@@ -424,7 +424,9 @@ class MimeMagic {
                                        $match= array();
                                        $prog= "";
 
-                                       if (preg_match('%/?([^\s]+/)(w+)%sim',$head,$match)) $script= $match[2];
+                                       if (preg_match('%/?([^\s]+/)(w+)%sim',$head,$match)) {
+                                               $script= $match[2]; // FIXME: $script variable not used; should this be "$prog = $match[2];" instead?
+                                       }
 
                                        $mime= "application/x-$prog";
                                }
index 1c7791c..889899f 100644 (file)
@@ -504,6 +504,8 @@ class RecentChange
        function getIRCLine() {
                global $wgUseRCPatrol;
 
+               // FIXME: Would be good to replace these 2 extract() calls with something more explicit
+               // e.g. list ($rc_type, $rc_id) = array_values ($this->mAttribs); [or something like that]
                extract($this->mAttribs);
                extract($this->mExtra);
 
index 3e4f5d3..f7a862a 100644 (file)
@@ -392,7 +392,6 @@ class Skin extends Linker {
         * @return string
         */
        function getUserJs() {
-               $fname = 'Skin::getUserJs';
                wfProfileIn( __METHOD__ );
 
                global $wgStylePath;
@@ -1510,7 +1509,7 @@ END;
        /* these are used extensively in SkinTemplate, but also some other places */
        static function makeMainPageUrl( $urlaction = '' ) {
                $title = Title::newMainPage();
-               self::checkTitle( $title, $name );
+               self::checkTitle( $title, '' );
                return $title->getLocalURL( $urlaction );
        }
 
@@ -1576,7 +1575,7 @@ END;
        }
 
        # make sure we have some title to operate on
-       static function checkTitle( &$title, &$name ) {
+       static function checkTitle( &$title, $name ) {
                if( !is_object( $title ) ) {
                        $title = Title::newFromText( $name );
                        if( !is_object( $title ) ) {
index 4043aa0..015b8ca 100644 (file)
@@ -481,7 +481,7 @@ class SkinTemplate extends Skin {
         * @param mixed $str
         * @private
         */
-       function printOrError( &$str ) {
+       function printOrError( $str ) {
                echo $str;
        }
 
index 780e6f0..970e343 100644 (file)
@@ -838,7 +838,7 @@ class PreferencesForm {
 
                # Editing
                #
-               global $wgLivePreview, $wgUseRCPatrol;
+               global $wgLivePreview;
                $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'textboxsize' ) . '</legend>
                        <div>' .
                                wfInputLabel( wfMsg( 'rows' ), 'wpRows', 'wpRows', 3, $this->mRows ) .
index ce296b4..fa5a417 100644 (file)
@@ -71,7 +71,7 @@ function showChunk( $namespace = NS_MAIN, $prefix, $including = false, $from = n
                $out = wfMsgWikiHtml( 'allpagesbadtitle' );
        } else {
                list( $namespace, $prefixKey, $prefix ) = $prefixList;
-               list( $fromNs, $fromKey, $from ) = $fromList;
+               list( /* $fromNs */, $fromKey, $from ) = $fromList;
 
                ### FIXME: should complain if $fromNs != $namespace
 
index d2fd839..6a6d202 100644 (file)
@@ -304,7 +304,6 @@ class UploadForm {
                } else {
                        $finalExt = '';
                }
-               $fullExt = implode( '.', $ext );
 
                # If there was more than one "extension", reassemble the base
                # filename to prevent bogus complaints about length
index cdd31f5..fc7fc52 100644 (file)
@@ -52,9 +52,6 @@ class SpecialVersion {
                $version = self::getVersion();
                $dbr =& wfGetDB( DB_SLAVE );
 
-               global $wgLanguageNames, $wgLanguageCode;
-               $mwlang = $wgLanguageNames[$wgLanguageCode];
-
                $ret =
                "__NOTOC__
                This wiki is powered by '''[http://www.mediawiki.org/ MediaWiki]''',
index 33e19a2..e4ff3d4 100644 (file)
@@ -16,7 +16,7 @@ require_once( 'SpecialRecentchanges.php' );
  * @param $par Parameter passed to the page
  */
 function wfSpecialWatchlist( $par ) {
-       global $wgUser, $wgOut, $wgLang, $wgMemc, $wgRequest, $wgContLang;
+       global $wgUser, $wgOut, $wgLang, $wgRequest, $wgContLang;
        global $wgRCShowWatchingUsers, $wgEnotifWatchlist, $wgShowUpdatedMarker;
        global $wgEnotifWatchlist;
        $fname = 'wfSpecialWatchlist';