Kill various unused variables
authorSam Reed <reedy@users.mediawiki.org>
Sat, 29 Oct 2011 01:17:26 +0000 (01:17 +0000)
committerSam Reed <reedy@users.mediawiki.org>
Sat, 29 Oct 2011 01:17:26 +0000 (01:17 +0000)
Comment some out also

Add some bits of documentation

19 files changed:
includes/Article.php
includes/Block.php
includes/HttpFunctions.old.php
includes/RecentChange.php
includes/api/ApiWatch.php
includes/db/DatabasePostgres.php
includes/diff/WikiDiff3.php
includes/filerepo/FSRepo.php
includes/installer/PostgresInstaller.php
includes/json/Services_JSON.php
includes/logging/LogEntry.php
includes/logging/LogFormatter.php
includes/media/Bitmap.php
includes/parser/ParserOutput.php
includes/revisiondelete/RevisionDeleter.php
includes/specials/SpecialSearch.php
includes/upload/UploadStash.php
languages/messages/MessagesEn.php
tests/phpunit/includes/search/SearchEngineTest.php

index 546e2d9..46d26bc 100644 (file)
@@ -86,6 +86,7 @@ class Article extends Page {
        /**
         * Constructor from a page id
         * @param $id Int article ID to load
+        * @return Article|null
         */
        public static function newFromID( $id ) {
                $t = Title::newFromID( $id );
@@ -1008,6 +1009,7 @@ class Article extends Page {
 
        /**
         * Execute the uncached parse for action=view
+        * @return bool
         */
        public function doViewParse() {
                global $wgOut;
index 368ab81..ed1a192 100644 (file)
@@ -418,7 +418,6 @@ class Block {
                # Don't collide with expired blocks
                Block::purgeExpired();
 
-               $ipb_id = $dbw->nextSequenceValue( 'ipblocks_ipb_id_seq' );
                $dbw->insert(
                        'ipblocks',
                        $this->getDatabaseArray(),
index ddfa608..479b4d2 100644 (file)
@@ -9,5 +9,4 @@
  * This is for backwards compatibility.
  * @since 1.17
  */
-
 class HttpRequest extends MWHttpRequest { }
index d59f1aa..c87b37e 100644 (file)
@@ -58,12 +58,20 @@ class RecentChange {
 
        # Factory methods
 
+       /**
+        * @param $row
+        * @return RecentChange
+        */
        public static function newFromRow( $row ) {
                $rc = new RecentChange;
                $rc->loadFromRow( $row );
                return $rc;
        }
 
+       /**
+        * @staticw
+        * @return RecentChange
+        */
        public static function newFromCurRow( $row ) {
                $rc = new RecentChange;
                $rc->loadFromCurRow( $row );
@@ -137,6 +145,9 @@ class RecentChange {
                return $this->mTitle;
        }
 
+       /**
+        * @return bool|\Title
+        */
        public function getMovedToTitle() {
                if( $this->mMovedToTitle === false ) {
                        $this->mMovedToTitle = Title::makeTitle( $this->mAttribs['rc_moved_to_ns'],
@@ -145,7 +156,9 @@ class RecentChange {
                return $this->mMovedToTitle;
        }
 
-       # Writes the data in this object to the database
+       /**
+        * Writes the data in this object to the database
+        */
        public function save() {
                global $wgLocalInterwiki, $wgPutIPinRC, $wgRC2UDPAddress, $wgRC2UDPOmitBots;
                $fname = 'RecentChange::save';
@@ -180,7 +193,7 @@ class RecentChange {
 
                # Set the ID
                $this->mAttribs['rc_id'] = $dbw->insertId();
-               
+
                # Notify extensions
                wfRunHooks( 'RecentChange_save', array( &$this ) );
 
@@ -194,11 +207,11 @@ class RecentChange {
                if( $wgUseEnotif || $wgShowUpdatedMarker ) {
                        // Users
                        if( $this->mAttribs['rc_user'] ) {
-                               $editor = ($wgUser->getId() == $this->mAttribs['rc_user']) ? 
+                               $editor = ($wgUser->getId() == $this->mAttribs['rc_user']) ?
                                        $wgUser : User::newFromID( $this->mAttribs['rc_user'] );
                        // Anons
                        } else {
-                               $editor = ($wgUser->getName() == $this->mAttribs['rc_user_text']) ? 
+                               $editor = ($wgUser->getName() == $this->mAttribs['rc_user_text']) ?
                                        $wgUser : User::newFromName( $this->mAttribs['rc_user_text'], false );
                        }
                        # @todo FIXME: This would be better as an extension hook
@@ -211,7 +224,7 @@ class RecentChange {
                                $this->mAttribs['rc_last_oldid'] );
                }
        }
-       
+
        public function notifyRC2UDP() {
                global $wgRC2UDPAddress, $wgRC2UDPOmitBots;
                # Notify external application via UDP
@@ -250,7 +263,7 @@ class RecentChange {
                }
                return false;
        }
-       
+
        /**
         * Remove newlines, carriage returns and decode html entites
         * @param $text String
@@ -279,7 +292,7 @@ class RecentChange {
                }
                return $change->doMarkPatrolled( $wgUser, $auto );
        }
-       
+
        /**
         * Mark this RecentChange as patrolled
         *
@@ -321,7 +334,7 @@ class RecentChange {
                wfRunHooks( 'MarkPatrolledComplete', array($this->getAttribute('rc_id'), &$user, false) );
                return array();
        }
-       
+
        /**
         * Mark this RecentChange patrolled, without error checking
         * @return Integer: number of affected rows
@@ -470,7 +483,21 @@ class RecentChange {
                return $rc;
        }
 
-       public static function notifyLog( $timestamp, &$title, &$user, $actionComment, $ip='', $type, 
+       /**
+        * @param $timestamp
+        * @param $title
+        * @param $user
+        * @param $actionComment
+        * @param $ip string
+        * @param $type
+        * @param $action
+        * @param $target
+        * @param $logComment
+        * @param $params
+        * @param $newId int
+        * @return bool
+        */
+       public static function notifyLog( $timestamp, &$title, &$user, $actionComment, $ip='', $type,
                $action, $target, $logComment, $params, $newId=0 )
        {
                global $wgLogRestrictions;
@@ -544,14 +571,22 @@ class RecentChange {
                return $rc;
        }
 
-       # Initialises the members of this object from a mysql row object
+       /**
+        * Initialises the members of this object from a mysql row object
+        *
+        * @param $row
+        */
        public function loadFromRow( $row ) {
                $this->mAttribs = get_object_vars( $row );
                $this->mAttribs['rc_timestamp'] = wfTimestamp(TS_MW, $this->mAttribs['rc_timestamp']);
                $this->mAttribs['rc_deleted'] = $row->rc_deleted; // MUST be set
        }
 
-       # Makes a pseudo-RC entry from a cur row
+       /**
+        * Makes a pseudo-RC entry from a cur row
+        *
+        * @param $row
+        */
        public function loadFromCurRow( $row ) {
                $this->mAttribs = array(
                        'rc_timestamp' => wfTimestamp(TS_MW, $row->rev_timestamp),
@@ -593,6 +628,9 @@ class RecentChange {
                return isset( $this->mAttribs[$name] ) ? $this->mAttribs[$name] : null;
        }
 
+       /**
+        * @return array
+        */
        public function getAttributes() {
                return $this->mAttribs;
        }
@@ -600,6 +638,8 @@ class RecentChange {
        /**
         * Gets the end part of the diff URL associated with this object
         * Blank if no diff link should be displayed
+        * @param $forceCur
+        * @return string
         */
        public function diffLinkTrail( $forceCur ) {
                if( $this->mAttribs['rc_type'] == RC_EDIT ) {
@@ -616,6 +656,9 @@ class RecentChange {
                return $trail;
        }
 
+       /**
+        * @return string
+        */
        public function getIRCLine() {
                global $wgUseRCPatrol, $wgUseNPPatrol, $wgRC2UDPInterwikiPrefix, $wgLocalInterwiki,
                        $wgCanonicalServer, $wgScript;
@@ -684,18 +727,21 @@ class RecentChange {
                } else {
                        $titleString = "\00314[[\00307$title\00314]]";
                }
-               
+
                # see http://www.irssi.org/documentation/formats for some colour codes. prefix is \003,
                # no colour (\003) switches back to the term default
                $fullString = "$titleString\0034 $flag\00310 " .
                              "\00302$url\003 \0035*\003 \00303$user\003 \0035*\003 $szdiff \00310$comment\003\n";
-                       
+
                return $fullString;
        }
 
        /**
         * Returns the change size (HTML).
         * The lengths can be given optionally.
+        * @param $old int
+        * @param $new int
+        * @return string
         */
        public function getCharacterDifference( $old = 0, $new = 0 ) {
                if( $old === 0 ) {
index 3518ea8..9266fca 100644 (file)
@@ -53,7 +53,6 @@ class ApiWatch extends ApiBase {
                        $this->dieUsageMsg( array( 'invalidtitle', $params['title'] ) );
                }
 
-               $article = new Article( $title, 0 );
                $res = array( 'title' => $title->getPrefixedText() );
 
                if ( $params['unwatch'] ) {
index 04c70e6..d991680 100644 (file)
@@ -565,7 +565,7 @@ class DatabasePostgres extends DatabaseBase {
                $ignore = in_array( 'IGNORE', $insertOptions ) ? 'mw' : '';
 
                if( is_array( $insertOptions ) ) {
-                       $insertOptions = implode( ' ', $insertOptions );
+                       $insertOptions = implode( ' ', $insertOptions ); // FIXME: This is unused
                }
                if( !is_array( $selectOptions ) ) {
                        $selectOptions = array( $selectOptions );
index 27d3d5b..6672744 100644 (file)
@@ -546,9 +546,12 @@ class WikiDiff3 {
                }
 
                // return the middle diagonal with maximal progress.
-               return $max_progress[floor( $num_progress / 2 )];
+               return $max_progress[(int)floor( $num_progress / 2 )];
        }
 
+       /**
+        * @return mixed
+        */
        public function getLcsLength() {
                if ( $this->heuristicUsed && !$this->lcsLengthCorrectedForHeuristic ) {
                        $this->lcsLengthCorrectedForHeuristic = true;
index 99b8436..3e0ef06 100644 (file)
@@ -601,7 +601,6 @@ class FSRepo extends FileRepo {
                        list( $srcRel, $archiveRel ) = $pair;
                        $srcPath = "{$this->directory}/$srcRel";
                        $archivePath = "{$this->deletedDir}/$archiveRel";
-                       $good = true;
                        if ( file_exists( $archivePath ) ) {
                                # A file with this content hash is already archived
                                wfSuppressWarnings();
index 550efbd..b330f27 100644 (file)
@@ -429,8 +429,8 @@ class PostgresInstaller extends DatabaseInstaller {
                $conn = $status->value;
 
                $dbName = $this->getVar( 'wgDBname' );
-               $schema = $this->getVar( 'wgDBmwschema' );
-               $user = $this->getVar( 'wgDBuser' );
+               //$schema = $this->getVar( 'wgDBmwschema' );
+               //$user = $this->getVar( 'wgDBuser' );
                //$safeschema = $conn->addIdentifierQuotes( $schema );
                //$safeuser = $conn->addIdentifierQuotes( $user );
 
@@ -491,7 +491,7 @@ class PostgresInstaller extends DatabaseInstaller {
                }
                $conn = $status->value;
 
-               $schema = $this->getVar( 'wgDBmwschema' );
+               //$schema = $this->getVar( 'wgDBmwschema' );
                $safeuser = $conn->addIdentifierQuotes( $this->getVar( 'wgDBuser' ) );
                $safepass = $conn->addQuotes( $this->getVar( 'wgDBpassword' ) );
                //$safeschema = $conn->addIdentifierQuotes( $schema );
index 29cc361..b2090dc 100644 (file)
@@ -136,7 +136,7 @@ class Services_JSON
        {
                $this->use = $use;
        }
-       
+
        private static $mHavePear = null;
        /**
         * Returns cached result of class_exists('pear'), to avoid calling AutoLoader numerous times
@@ -872,7 +872,7 @@ if (class_exists('PEAR_Error')) {
                {
                        $this->message = $message;
                }
-               
+
                function __toString()
                {
                        return $this->message;
index 82d1ff1..0373d75 100644 (file)
@@ -127,8 +127,6 @@ class DatabaseLogEntry extends LogEntryBase {
                        'user_id', 'user_name', 'user_editcount',
                );
 
-               $conds = array();
-
                $joins = array(
                        // IP's don't have an entry in user table
                        'user' => array( 'LEFT JOIN', 'log_user=user_id' ),
@@ -321,7 +319,7 @@ class ManualLogEntry extends LogEntryBase {
        }
 
        /**
-        * Set extra log parameters. 
+        * Set extra log parameters.
         * You can pass params to the log action message
         * by prefixing the keys with a number and colon.
         * The numbering should start with number 4, the
index 93497c6..1d7cd9d 100644 (file)
@@ -481,7 +481,6 @@ class NewUsersLogFormatter extends LogFormatter {
        }
 
        public function getComment() {
-               $subtype = $this->entry->getSubtype();
                $timestamp = wfTimestamp( TS_MW, $this->entry->getTimestamp() );
                if ( $timestamp < '20080129000000' ) {
                        # Suppress $comment from old entries (before 2008-01-29),
@@ -490,4 +489,4 @@ class NewUsersLogFormatter extends LogFormatter {
                }
                return parent::getComment();
        }
-}
\ No newline at end of file
+}
index a5cc711..95b916d 100644 (file)
@@ -21,12 +21,11 @@ class BitmapHandler extends ImageHandler {
         * @return bool
         */
        function normaliseParams( $image, &$params ) {
-               
+
                if ( !parent::normaliseParams( $image, $params ) ) {
                        return false;
                }
 
-               $mimeType = $image->getMimeType();
                # Obtain the source, pre-rotation dimensions
                $srcWidth = $image->getWidth( $params['page'] );
                $srcHeight = $image->getHeight( $params['page'] );
@@ -42,39 +41,39 @@ class BitmapHandler extends ImageHandler {
                                return true;
                        }
                }
-               
+
                return true;
        }
-       
+
        /**
-        * Check if the file is smaller than the maximum image area for 
+        * Check if the file is smaller than the maximum image area for
         * thumbnailing. Check will always pass if the scaler is 'hookaborted' or
         * if the scaler is 'im' and the mime type is 'image/jpeg'
-        * 
+        *
         * @param File $image
-        * @param string $scaler 
+        * @param string $scaler
         */
        function checkImageArea( $image, $scaler ) {
                global $wgMaxImageArea;
                # Don't thumbnail an image so big that it will fill hard drives and send servers into swap
                # JPEG has the handy property of allowing thumbnailing without full decompression, so we make
                # an exception for it.
-               
-               
+
+
                if ( $image->getMimeType() == 'image/jpeg' && $scaler == 'im' )
                {
                        # ImageMagick can efficiently downsize jpg images without loading
                        # the entire file in memory
                        return true;
                }
-               
+
                if ( $scaler == 'hookaborted' )
                {
-                       # If a hook wants to transform the image, it is responsible for 
+                       # If a hook wants to transform the image, it is responsible for
                        # checking the image size, so abort here
                        return true;
                }
-               
+
                # Do the actual check
                return $this->getImageArea( $image, $image->getWidth(), $image->getHeight() ) <= $wgMaxImageArea;
        }
@@ -184,7 +183,7 @@ class BitmapHandler extends ImageHandler {
                        wfDebug( __METHOD__ . ": Hook to BitmapHandlerTransform created an mto\n" );
                        $scaler = 'hookaborted';
                }
-               
+
                # Check max image area
                if ( !$this->checkImageArea( $image, $scaler ) )
                {
index d7a674c..2e80f4e 100644 (file)
@@ -158,10 +158,8 @@ class ParserOutput extends CacheTime {
                if ( $this->mEditSectionTokens ) {
                        return preg_replace_callback( ParserOutput::EDITSECTION_REGEX,
                                array( &$this, 'replaceEditSectionLinksCallback' ), $this->mText );
-               } else {
-                       return preg_replace( ParserOutput::EDITSECTION_REGEX, '', $this->mText );
                }
-               return $this->mText;
+               return preg_replace( ParserOutput::EDITSECTION_REGEX, '', $this->mText );
        }
 
        /**
index 0c2197a..59a9fa8 100644 (file)
@@ -121,7 +121,7 @@ class RevisionDeleter {
 
                if ( count( $paramArray ) >= 2 ) {
                        // Different revision types use different URL params...
-                       $originalKey = $key = $paramArray[0];
+                       $key = $paramArray[0];
                        // $paramArray[1] is a CSV of the IDs
                        $Ids = explode( ',', $paramArray[1] );
 
index 857a38c..05416c9 100644 (file)
@@ -407,7 +407,7 @@ class SpecialSearch extends SpecialPage {
                        $this->getOutput()->addHtml( '<p></p>' );
                        return;
                }
-               $messageName = '';
+
                if( $t->isKnown() ) {
                        $messageName = 'searchmenu-exists';
                } elseif( $t->userCan( 'create' ) ) {
index 3d624a5..4fac9a9 100644 (file)
@@ -91,8 +91,6 @@ class UploadStash {
                        }
                }
 
-               $dbr = $this->repo->getSlaveDb();
-
                if ( !isset( $this->fileMetadata[$key] ) ) {
                        if ( !$this->fetchFileMetadata( $key ) ) {
                                // If nothing was received, it's likely due to replication lag.  Check the master to see if the record is there.
@@ -188,7 +186,7 @@ class UploadStash {
                $usec = substr($usec, 2);
                $key = wfBaseConvert( $sec . $usec, 10, 36 ) . '.' .
                        wfBaseConvert( mt_rand(), 10, 36 ) . '.'.
-                       $this->userId . '.' . 
+                       $this->userId . '.' .
                        $extension;
 
                $this->fileProps[$key] = $fileProps;
index 4c65724..fd09141 100644 (file)
@@ -4525,8 +4525,7 @@ Images are shown in full resolution, other file types are started with their ass
 'specialpages-summary'           => '', # do not translate or duplicate this message to other languages
 'specialpages-note'              => '----
 * Normal special pages.
-* <span class="mw-specialpagerestricted">Restricted special pages.</span>
-* <span class="mw-specialpagecached">Cached special pages (might be obsolete).</span>',
+* <span class="mw-specialpagerestricted">Restricted special pages.</span>',
 'specialpages-group-maintenance' => 'Maintenance reports',
 'specialpages-group-other'       => 'Other special pages',
 'specialpages-group-login'       => 'Login / sign up',
index e3684c9..4cb68d5 100644 (file)
@@ -85,7 +85,6 @@ class SearchEngineTest extends MediaWikiTestCase {
         * @param $n Integer: unused
         */
        function insertPage( $pageName, $text, $ns ) {
-               $dbw = $this->db;
                $title = Title::newFromText( $pageName );
 
                $user = User::newFromName( 'WikiSysop' );