From 9d41b9505369201b8e4c069c3cbc060d1630bf22 Mon Sep 17 00:00:00 2001 From: Sam Reed Date: Sat, 29 Oct 2011 01:17:26 +0000 Subject: [PATCH] Kill various unused variables Comment some out also Add some bits of documentation --- includes/Article.php | 2 + includes/Block.php | 1 - includes/HttpFunctions.old.php | 1 - includes/RecentChange.php | 72 +++++++++++++++---- includes/api/ApiWatch.php | 1 - includes/db/DatabasePostgres.php | 2 +- includes/diff/WikiDiff3.php | 5 +- includes/filerepo/FSRepo.php | 1 - includes/installer/PostgresInstaller.php | 6 +- includes/json/Services_JSON.php | 4 +- includes/logging/LogEntry.php | 4 +- includes/logging/LogFormatter.php | 3 +- includes/media/Bitmap.php | 25 ++++--- includes/parser/ParserOutput.php | 4 +- includes/revisiondelete/RevisionDeleter.php | 2 +- includes/specials/SpecialSearch.php | 2 +- includes/upload/UploadStash.php | 4 +- languages/messages/MessagesEn.php | 3 +- .../includes/search/SearchEngineTest.php | 1 - 19 files changed, 90 insertions(+), 53 deletions(-) diff --git a/includes/Article.php b/includes/Article.php index 546e2d9066..46d26bce70 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -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; diff --git a/includes/Block.php b/includes/Block.php index 368ab81208..ed1a1920fd 100644 --- a/includes/Block.php +++ b/includes/Block.php @@ -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(), diff --git a/includes/HttpFunctions.old.php b/includes/HttpFunctions.old.php index ddfa608eec..479b4d2347 100644 --- a/includes/HttpFunctions.old.php +++ b/includes/HttpFunctions.old.php @@ -9,5 +9,4 @@ * This is for backwards compatibility. * @since 1.17 */ - class HttpRequest extends MWHttpRequest { } diff --git a/includes/RecentChange.php b/includes/RecentChange.php index d59f1aa273..c87b37e70b 100644 --- a/includes/RecentChange.php +++ b/includes/RecentChange.php @@ -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 ) { diff --git a/includes/api/ApiWatch.php b/includes/api/ApiWatch.php index 3518ea8093..9266fca8c4 100644 --- a/includes/api/ApiWatch.php +++ b/includes/api/ApiWatch.php @@ -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'] ) { diff --git a/includes/db/DatabasePostgres.php b/includes/db/DatabasePostgres.php index 04c70e6d51..d991680fe9 100644 --- a/includes/db/DatabasePostgres.php +++ b/includes/db/DatabasePostgres.php @@ -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 ); diff --git a/includes/diff/WikiDiff3.php b/includes/diff/WikiDiff3.php index 27d3d5b83d..667274456d 100644 --- a/includes/diff/WikiDiff3.php +++ b/includes/diff/WikiDiff3.php @@ -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; diff --git a/includes/filerepo/FSRepo.php b/includes/filerepo/FSRepo.php index 99b8436f9d..3e0ef06e50 100644 --- a/includes/filerepo/FSRepo.php +++ b/includes/filerepo/FSRepo.php @@ -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(); diff --git a/includes/installer/PostgresInstaller.php b/includes/installer/PostgresInstaller.php index 550efbdb00..b330f2758f 100644 --- a/includes/installer/PostgresInstaller.php +++ b/includes/installer/PostgresInstaller.php @@ -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 ); diff --git a/includes/json/Services_JSON.php b/includes/json/Services_JSON.php index 29cc36179c..b2090dce7b 100644 --- a/includes/json/Services_JSON.php +++ b/includes/json/Services_JSON.php @@ -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; diff --git a/includes/logging/LogEntry.php b/includes/logging/LogEntry.php index 82d1ff1619..0373d75f98 100644 --- a/includes/logging/LogEntry.php +++ b/includes/logging/LogEntry.php @@ -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 diff --git a/includes/logging/LogFormatter.php b/includes/logging/LogFormatter.php index 93497c673b..1d7cd9d50d 100644 --- a/includes/logging/LogFormatter.php +++ b/includes/logging/LogFormatter.php @@ -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 +} diff --git a/includes/media/Bitmap.php b/includes/media/Bitmap.php index a5cc711d9a..95b916dd2a 100644 --- a/includes/media/Bitmap.php +++ b/includes/media/Bitmap.php @@ -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 ) ) { diff --git a/includes/parser/ParserOutput.php b/includes/parser/ParserOutput.php index d7a674cd96..2e80f4e30f 100644 --- a/includes/parser/ParserOutput.php +++ b/includes/parser/ParserOutput.php @@ -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 ); } /** diff --git a/includes/revisiondelete/RevisionDeleter.php b/includes/revisiondelete/RevisionDeleter.php index 0c2197ac54..59a9fa820b 100644 --- a/includes/revisiondelete/RevisionDeleter.php +++ b/includes/revisiondelete/RevisionDeleter.php @@ -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] ); diff --git a/includes/specials/SpecialSearch.php b/includes/specials/SpecialSearch.php index 857a38c0f4..05416c90fc 100644 --- a/includes/specials/SpecialSearch.php +++ b/includes/specials/SpecialSearch.php @@ -407,7 +407,7 @@ class SpecialSearch extends SpecialPage { $this->getOutput()->addHtml( '

' ); return; } - $messageName = ''; + if( $t->isKnown() ) { $messageName = 'searchmenu-exists'; } elseif( $t->userCan( 'create' ) ) { diff --git a/includes/upload/UploadStash.php b/includes/upload/UploadStash.php index 3d624a58da..4fac9a960c 100644 --- a/includes/upload/UploadStash.php +++ b/includes/upload/UploadStash.php @@ -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; diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index 4c65724e48..fd0914195c 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -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. -* Restricted special pages. -* Cached special pages (might be obsolete).', +* Restricted special pages.', 'specialpages-group-maintenance' => 'Maintenance reports', 'specialpages-group-other' => 'Other special pages', 'specialpages-group-login' => 'Login / sign up', diff --git a/tests/phpunit/includes/search/SearchEngineTest.php b/tests/phpunit/includes/search/SearchEngineTest.php index e3684c9753..4cb68d5083 100644 --- a/tests/phpunit/includes/search/SearchEngineTest.php +++ b/tests/phpunit/includes/search/SearchEngineTest.php @@ -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' ); -- 2.20.1