r101240 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r101239‎ | r101240 | r101241 >
Date:01:17, 29 October 2011
Author:reedy
Status:ok
Tags:
Comment:
Kill various unused variables

Comment some out also

Add some bits of documentation
Modified paths:
  • /trunk/phase3/includes/Article.php (modified) (history)
  • /trunk/phase3/includes/Block.php (modified) (history)
  • /trunk/phase3/includes/HttpFunctions.old.php (modified) (history)
  • /trunk/phase3/includes/RecentChange.php (modified) (history)
  • /trunk/phase3/includes/api/ApiWatch.php (modified) (history)
  • /trunk/phase3/includes/db/DatabasePostgres.php (modified) (history)
  • /trunk/phase3/includes/diff/WikiDiff3.php (modified) (history)
  • /trunk/phase3/includes/filerepo/FSRepo.php (modified) (history)
  • /trunk/phase3/includes/installer/PostgresInstaller.php (modified) (history)
  • /trunk/phase3/includes/json/Services_JSON.php (modified) (history)
  • /trunk/phase3/includes/logging/LogEntry.php (modified) (history)
  • /trunk/phase3/includes/logging/LogFormatter.php (modified) (history)
  • /trunk/phase3/includes/media/Bitmap.php (modified) (history)
  • /trunk/phase3/includes/parser/ParserOutput.php (modified) (history)
  • /trunk/phase3/includes/revisiondelete/RevisionDeleter.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialSearch.php (modified) (history)
  • /trunk/phase3/includes/upload/UploadStash.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)
  • /trunk/phase3/tests/phpunit/includes/search/SearchEngineTest.php (modified) (history)

Diff [purge]

Index: trunk/phase3/tests/phpunit/includes/search/SearchEngineTest.php
@@ -85,7 +85,6 @@
8686 * @param $n Integer: unused
8787 */
8888 function insertPage( $pageName, $text, $ns ) {
89 - $dbw = $this->db;
9089 $title = Title::newFromText( $pageName );
9190
9291 $user = User::newFromName( 'WikiSysop' );
Index: trunk/phase3/includes/upload/UploadStash.php
@@ -91,8 +91,6 @@
9292 }
9393 }
9494
95 - $dbr = $this->repo->getSlaveDb();
96 -
9795 if ( !isset( $this->fileMetadata[$key] ) ) {
9896 if ( !$this->fetchFileMetadata( $key ) ) {
9997 // 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 @@
189187 $usec = substr($usec, 2);
190188 $key = wfBaseConvert( $sec . $usec, 10, 36 ) . '.' .
191189 wfBaseConvert( mt_rand(), 10, 36 ) . '.'.
192 - $this->userId . '.' .
 190+ $this->userId . '.' .
193191 $extension;
194192
195193 $this->fileProps[$key] = $fileProps;
Index: trunk/phase3/includes/diff/WikiDiff3.php
@@ -546,9 +546,12 @@
547547 }
548548
549549 // return the middle diagonal with maximal progress.
550 - return $max_progress[floor( $num_progress / 2 )];
 550+ return $max_progress[(int)floor( $num_progress / 2 )];
551551 }
552552
 553+ /**
 554+ * @return mixed
 555+ */
553556 public function getLcsLength() {
554557 if ( $this->heuristicUsed && !$this->lcsLengthCorrectedForHeuristic ) {
555558 $this->lcsLengthCorrectedForHeuristic = true;
Index: trunk/phase3/includes/json/Services_JSON.php
@@ -136,7 +136,7 @@
137137 {
138138 $this->use = $use;
139139 }
140 -
 140+
141141 private static $mHavePear = null;
142142 /**
143143 * Returns cached result of class_exists('pear'), to avoid calling AutoLoader numerous times
@@ -872,7 +872,7 @@
873873 {
874874 $this->message = $message;
875875 }
876 -
 876+
877877 function __toString()
878878 {
879879 return $this->message;
Index: trunk/phase3/includes/Article.php
@@ -86,6 +86,7 @@
8787 /**
8888 * Constructor from a page id
8989 * @param $id Int article ID to load
 90+ * @return Article|null
9091 */
9192 public static function newFromID( $id ) {
9293 $t = Title::newFromID( $id );
@@ -1008,6 +1009,7 @@
10091010
10101011 /**
10111012 * Execute the uncached parse for action=view
 1013+ * @return bool
10121014 */
10131015 public function doViewParse() {
10141016 global $wgOut;
Index: trunk/phase3/includes/RecentChange.php
@@ -58,12 +58,20 @@
5959
6060 # Factory methods
6161
 62+ /**
 63+ * @param $row
 64+ * @return RecentChange
 65+ */
6266 public static function newFromRow( $row ) {
6367 $rc = new RecentChange;
6468 $rc->loadFromRow( $row );
6569 return $rc;
6670 }
6771
 72+ /**
 73+ * @staticw
 74+ * @return RecentChange
 75+ */
6876 public static function newFromCurRow( $row ) {
6977 $rc = new RecentChange;
7078 $rc->loadFromCurRow( $row );
@@ -137,6 +145,9 @@
138146 return $this->mTitle;
139147 }
140148
 149+ /**
 150+ * @return bool|\Title
 151+ */
141152 public function getMovedToTitle() {
142153 if( $this->mMovedToTitle === false ) {
143154 $this->mMovedToTitle = Title::makeTitle( $this->mAttribs['rc_moved_to_ns'],
@@ -145,7 +156,9 @@
146157 return $this->mMovedToTitle;
147158 }
148159
149 - # Writes the data in this object to the database
 160+ /**
 161+ * Writes the data in this object to the database
 162+ */
150163 public function save() {
151164 global $wgLocalInterwiki, $wgPutIPinRC, $wgRC2UDPAddress, $wgRC2UDPOmitBots;
152165 $fname = 'RecentChange::save';
@@ -180,7 +193,7 @@
181194
182195 # Set the ID
183196 $this->mAttribs['rc_id'] = $dbw->insertId();
184 -
 197+
185198 # Notify extensions
186199 wfRunHooks( 'RecentChange_save', array( &$this ) );
187200
@@ -194,11 +207,11 @@
195208 if( $wgUseEnotif || $wgShowUpdatedMarker ) {
196209 // Users
197210 if( $this->mAttribs['rc_user'] ) {
198 - $editor = ($wgUser->getId() == $this->mAttribs['rc_user']) ?
 211+ $editor = ($wgUser->getId() == $this->mAttribs['rc_user']) ?
199212 $wgUser : User::newFromID( $this->mAttribs['rc_user'] );
200213 // Anons
201214 } else {
202 - $editor = ($wgUser->getName() == $this->mAttribs['rc_user_text']) ?
 215+ $editor = ($wgUser->getName() == $this->mAttribs['rc_user_text']) ?
203216 $wgUser : User::newFromName( $this->mAttribs['rc_user_text'], false );
204217 }
205218 # @todo FIXME: This would be better as an extension hook
@@ -211,7 +224,7 @@
212225 $this->mAttribs['rc_last_oldid'] );
213226 }
214227 }
215 -
 228+
216229 public function notifyRC2UDP() {
217230 global $wgRC2UDPAddress, $wgRC2UDPOmitBots;
218231 # Notify external application via UDP
@@ -250,7 +263,7 @@
251264 }
252265 return false;
253266 }
254 -
 267+
255268 /**
256269 * Remove newlines, carriage returns and decode html entites
257270 * @param $text String
@@ -279,7 +292,7 @@
280293 }
281294 return $change->doMarkPatrolled( $wgUser, $auto );
282295 }
283 -
 296+
284297 /**
285298 * Mark this RecentChange as patrolled
286299 *
@@ -321,7 +334,7 @@
322335 wfRunHooks( 'MarkPatrolledComplete', array($this->getAttribute('rc_id'), &$user, false) );
323336 return array();
324337 }
325 -
 338+
326339 /**
327340 * Mark this RecentChange patrolled, without error checking
328341 * @return Integer: number of affected rows
@@ -470,7 +483,21 @@
471484 return $rc;
472485 }
473486
474 - public static function notifyLog( $timestamp, &$title, &$user, $actionComment, $ip='', $type,
 487+ /**
 488+ * @param $timestamp
 489+ * @param $title
 490+ * @param $user
 491+ * @param $actionComment
 492+ * @param $ip string
 493+ * @param $type
 494+ * @param $action
 495+ * @param $target
 496+ * @param $logComment
 497+ * @param $params
 498+ * @param $newId int
 499+ * @return bool
 500+ */
 501+ public static function notifyLog( $timestamp, &$title, &$user, $actionComment, $ip='', $type,
475502 $action, $target, $logComment, $params, $newId=0 )
476503 {
477504 global $wgLogRestrictions;
@@ -544,14 +571,22 @@
545572 return $rc;
546573 }
547574
548 - # Initialises the members of this object from a mysql row object
 575+ /**
 576+ * Initialises the members of this object from a mysql row object
 577+ *
 578+ * @param $row
 579+ */
549580 public function loadFromRow( $row ) {
550581 $this->mAttribs = get_object_vars( $row );
551582 $this->mAttribs['rc_timestamp'] = wfTimestamp(TS_MW, $this->mAttribs['rc_timestamp']);
552583 $this->mAttribs['rc_deleted'] = $row->rc_deleted; // MUST be set
553584 }
554585
555 - # Makes a pseudo-RC entry from a cur row
 586+ /**
 587+ * Makes a pseudo-RC entry from a cur row
 588+ *
 589+ * @param $row
 590+ */
556591 public function loadFromCurRow( $row ) {
557592 $this->mAttribs = array(
558593 'rc_timestamp' => wfTimestamp(TS_MW, $row->rev_timestamp),
@@ -593,6 +628,9 @@
594629 return isset( $this->mAttribs[$name] ) ? $this->mAttribs[$name] : null;
595630 }
596631
 632+ /**
 633+ * @return array
 634+ */
597635 public function getAttributes() {
598636 return $this->mAttribs;
599637 }
@@ -600,6 +638,8 @@
601639 /**
602640 * Gets the end part of the diff URL associated with this object
603641 * Blank if no diff link should be displayed
 642+ * @param $forceCur
 643+ * @return string
604644 */
605645 public function diffLinkTrail( $forceCur ) {
606646 if( $this->mAttribs['rc_type'] == RC_EDIT ) {
@@ -616,6 +656,9 @@
617657 return $trail;
618658 }
619659
 660+ /**
 661+ * @return string
 662+ */
620663 public function getIRCLine() {
621664 global $wgUseRCPatrol, $wgUseNPPatrol, $wgRC2UDPInterwikiPrefix, $wgLocalInterwiki,
622665 $wgCanonicalServer, $wgScript;
@@ -684,18 +727,21 @@
685728 } else {
686729 $titleString = "\00314[[\00307$title\00314]]";
687730 }
688 -
 731+
689732 # see http://www.irssi.org/documentation/formats for some colour codes. prefix is \003,
690733 # no colour (\003) switches back to the term default
691734 $fullString = "$titleString\0034 $flag\00310 " .
692735 "\00302$url\003 \0035*\003 \00303$user\003 \0035*\003 $szdiff \00310$comment\003\n";
693 -
 736+
694737 return $fullString;
695738 }
696739
697740 /**
698741 * Returns the change size (HTML).
699742 * The lengths can be given optionally.
 743+ * @param $old int
 744+ * @param $new int
 745+ * @return string
700746 */
701747 public function getCharacterDifference( $old = 0, $new = 0 ) {
702748 if( $old === 0 ) {
Index: trunk/phase3/includes/parser/ParserOutput.php
@@ -158,10 +158,8 @@
159159 if ( $this->mEditSectionTokens ) {
160160 return preg_replace_callback( ParserOutput::EDITSECTION_REGEX,
161161 array( &$this, 'replaceEditSectionLinksCallback' ), $this->mText );
162 - } else {
163 - return preg_replace( ParserOutput::EDITSECTION_REGEX, '', $this->mText );
164162 }
165 - return $this->mText;
 163+ return preg_replace( ParserOutput::EDITSECTION_REGEX, '', $this->mText );
166164 }
167165
168166 /**
Index: trunk/phase3/includes/db/DatabasePostgres.php
@@ -565,7 +565,7 @@
566566 $ignore = in_array( 'IGNORE', $insertOptions ) ? 'mw' : '';
567567
568568 if( is_array( $insertOptions ) ) {
569 - $insertOptions = implode( ' ', $insertOptions );
 569+ $insertOptions = implode( ' ', $insertOptions ); // FIXME: This is unused
570570 }
571571 if( !is_array( $selectOptions ) ) {
572572 $selectOptions = array( $selectOptions );
Index: trunk/phase3/includes/filerepo/FSRepo.php
@@ -601,7 +601,6 @@
602602 list( $srcRel, $archiveRel ) = $pair;
603603 $srcPath = "{$this->directory}/$srcRel";
604604 $archivePath = "{$this->deletedDir}/$archiveRel";
605 - $good = true;
606605 if ( file_exists( $archivePath ) ) {
607606 # A file with this content hash is already archived
608607 wfSuppressWarnings();
Index: trunk/phase3/includes/revisiondelete/RevisionDeleter.php
@@ -121,7 +121,7 @@
122122
123123 if ( count( $paramArray ) >= 2 ) {
124124 // Different revision types use different URL params...
125 - $originalKey = $key = $paramArray[0];
 125+ $key = $paramArray[0];
126126 // $paramArray[1] is a CSV of the IDs
127127 $Ids = explode( ',', $paramArray[1] );
128128
Index: trunk/phase3/includes/logging/LogEntry.php
@@ -127,8 +127,6 @@
128128 'user_id', 'user_name', 'user_editcount',
129129 );
130130
131 - $conds = array();
132 -
133131 $joins = array(
134132 // IP's don't have an entry in user table
135133 'user' => array( 'LEFT JOIN', 'log_user=user_id' ),
@@ -321,7 +319,7 @@
322320 }
323321
324322 /**
325 - * Set extra log parameters.
 323+ * Set extra log parameters.
326324 * You can pass params to the log action message
327325 * by prefixing the keys with a number and colon.
328326 * The numbering should start with number 4, the
Index: trunk/phase3/includes/logging/LogFormatter.php
@@ -481,7 +481,6 @@
482482 }
483483
484484 public function getComment() {
485 - $subtype = $this->entry->getSubtype();
486485 $timestamp = wfTimestamp( TS_MW, $this->entry->getTimestamp() );
487486 if ( $timestamp < '20080129000000' ) {
488487 # Suppress $comment from old entries (before 2008-01-29),
@@ -490,4 +489,4 @@
491490 }
492491 return parent::getComment();
493492 }
494 -}
\ No newline at end of file
 493+}
Index: trunk/phase3/includes/installer/PostgresInstaller.php
@@ -429,8 +429,8 @@
430430 $conn = $status->value;
431431
432432 $dbName = $this->getVar( 'wgDBname' );
433 - $schema = $this->getVar( 'wgDBmwschema' );
434 - $user = $this->getVar( 'wgDBuser' );
 433+ //$schema = $this->getVar( 'wgDBmwschema' );
 434+ //$user = $this->getVar( 'wgDBuser' );
435435 //$safeschema = $conn->addIdentifierQuotes( $schema );
436436 //$safeuser = $conn->addIdentifierQuotes( $user );
437437
@@ -491,7 +491,7 @@
492492 }
493493 $conn = $status->value;
494494
495 - $schema = $this->getVar( 'wgDBmwschema' );
 495+ //$schema = $this->getVar( 'wgDBmwschema' );
496496 $safeuser = $conn->addIdentifierQuotes( $this->getVar( 'wgDBuser' ) );
497497 $safepass = $conn->addQuotes( $this->getVar( 'wgDBpassword' ) );
498498 //$safeschema = $conn->addIdentifierQuotes( $schema );
Index: trunk/phase3/includes/api/ApiWatch.php
@@ -53,7 +53,6 @@
5454 $this->dieUsageMsg( array( 'invalidtitle', $params['title'] ) );
5555 }
5656
57 - $article = new Article( $title, 0 );
5857 $res = array( 'title' => $title->getPrefixedText() );
5958
6059 if ( $params['unwatch'] ) {
Index: trunk/phase3/includes/media/Bitmap.php
@@ -21,12 +21,11 @@
2222 * @return bool
2323 */
2424 function normaliseParams( $image, &$params ) {
25 -
 25+
2626 if ( !parent::normaliseParams( $image, $params ) ) {
2727 return false;
2828 }
2929
30 - $mimeType = $image->getMimeType();
3130 # Obtain the source, pre-rotation dimensions
3231 $srcWidth = $image->getWidth( $params['page'] );
3332 $srcHeight = $image->getHeight( $params['page'] );
@@ -42,39 +41,39 @@
4342 return true;
4443 }
4544 }
46 -
 45+
4746 return true;
4847 }
49 -
 48+
5049 /**
51 - * Check if the file is smaller than the maximum image area for
 50+ * Check if the file is smaller than the maximum image area for
5251 * thumbnailing. Check will always pass if the scaler is 'hookaborted' or
5352 * if the scaler is 'im' and the mime type is 'image/jpeg'
54 - *
 53+ *
5554 * @param File $image
56 - * @param string $scaler
 55+ * @param string $scaler
5756 */
5857 function checkImageArea( $image, $scaler ) {
5958 global $wgMaxImageArea;
6059 # Don't thumbnail an image so big that it will fill hard drives and send servers into swap
6160 # JPEG has the handy property of allowing thumbnailing without full decompression, so we make
6261 # an exception for it.
63 -
64 -
 62+
 63+
6564 if ( $image->getMimeType() == 'image/jpeg' && $scaler == 'im' )
6665 {
6766 # ImageMagick can efficiently downsize jpg images without loading
6867 # the entire file in memory
6968 return true;
7069 }
71 -
 70+
7271 if ( $scaler == 'hookaborted' )
7372 {
74 - # If a hook wants to transform the image, it is responsible for
 73+ # If a hook wants to transform the image, it is responsible for
7574 # checking the image size, so abort here
7675 return true;
7776 }
78 -
 77+
7978 # Do the actual check
8079 return $this->getImageArea( $image, $image->getWidth(), $image->getHeight() ) <= $wgMaxImageArea;
8180 }
@@ -184,7 +183,7 @@
185184 wfDebug( __METHOD__ . ": Hook to BitmapHandlerTransform created an mto\n" );
186185 $scaler = 'hookaborted';
187186 }
188 -
 187+
189188 # Check max image area
190189 if ( !$this->checkImageArea( $image, $scaler ) )
191190 {
Index: trunk/phase3/includes/HttpFunctions.old.php
@@ -9,5 +9,4 @@
1010 * This is for backwards compatibility.
1111 * @since 1.17
1212 */
13 -
1413 class HttpRequest extends MWHttpRequest { }
Index: trunk/phase3/includes/specials/SpecialSearch.php
@@ -407,7 +407,7 @@
408408 $this->getOutput()->addHtml( '<p></p>' );
409409 return;
410410 }
411 - $messageName = '';
 411+
412412 if( $t->isKnown() ) {
413413 $messageName = 'searchmenu-exists';
414414 } elseif( $t->userCan( 'create' ) ) {
Index: trunk/phase3/includes/Block.php
@@ -418,7 +418,6 @@
419419 # Don't collide with expired blocks
420420 Block::purgeExpired();
421421
422 - $ipb_id = $dbw->nextSequenceValue( 'ipblocks_ipb_id_seq' );
423422 $dbw->insert(
424423 'ipblocks',
425424 $this->getDatabaseArray(),
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -4525,8 +4525,7 @@
45264526 'specialpages-summary' => '', # do not translate or duplicate this message to other languages
45274527 'specialpages-note' => '----
45284528 * Normal special pages.
4529 -* <span class="mw-specialpagerestricted">Restricted special pages.</span>
4530 -* <span class="mw-specialpagecached">Cached special pages (might be obsolete).</span>',
 4529+* <span class="mw-specialpagerestricted">Restricted special pages.</span>',
45314530 'specialpages-group-maintenance' => 'Maintenance reports',
45324531 'specialpages-group-other' => 'Other special pages',
45334532 'specialpages-group-login' => 'Login / sign up',

Status & tagging log