r84042 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r84041‎ | r84042 | r84043 >
Date:18:35, 15 March 2011
Author:ialex
Status:ok
Tags:
Comment:
Get ride of extract() calls in RecentChange::getIRCLine()
Modified paths:
  • /trunk/phase3/includes/RecentChange.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/RecentChange.php
@@ -616,29 +616,24 @@
617617 public function getIRCLine() {
618618 global $wgUseRCPatrol, $wgUseNPPatrol, $wgRC2UDPInterwikiPrefix, $wgLocalInterwiki;
619619
620 - // FIXME: Would be good to replace these 2 extract() calls with something more explicit
621 - // e.g. list ($rc_type, $rc_id) = array_values ($this->mAttribs); [or something like that]
622 - extract($this->mAttribs);
623 - extract($this->mExtra);
624 -
625 - if( $rc_type == RC_LOG ) {
626 - $titleObj = Title::newFromText( "Log/$rc_log_type", NS_SPECIAL );
 620+ if( $this->mAttribs['rc_type'] == RC_LOG ) {
 621+ $titleObj = Title::newFromText( 'Log/' . $this->mAttribs['rc_log_type'], NS_SPECIAL );
627622 } else {
628623 $titleObj =& $this->getTitle();
629624 }
630625 $title = $titleObj->getPrefixedText();
631626 $title = self::cleanupForIRC( $title );
632627
633 - if( $rc_type == RC_LOG ) {
 628+ if( $this->mAttribs['rc_type'] == RC_LOG ) {
634629 $url = '';
635630 } else {
636 - if( $rc_type == RC_NEW ) {
637 - $url = "oldid=$rc_this_oldid";
 631+ if( $this->mAttribs['rc_type'] == RC_NEW ) {
 632+ $url = 'oldid=' . $this->mAttribs['rc_this_oldid'];
638633 } else {
639 - $url = "diff=$rc_this_oldid&oldid=$rc_last_oldid";
 634+ $url = 'diff=' . $this->mAttribs['rc_this_oldid'] . '&oldid=' . $this->mAttribs['rc_last_oldid'];
640635 }
641 - if( $wgUseRCPatrol || ($rc_type == RC_NEW && $wgUseNPPatrol) ) {
642 - $url .= "&rcid=$rc_id";
 636+ if ( $wgUseRCPatrol || ( $this->mAttribs['rc_type'] == RC_NEW && $wgUseNPPatrol ) ) {
 637+ $url .= '&rcid=' . $this->mAttribs['rc_id'];
643638 }
644639 // XXX: *HACK* this should use getFullURL(), hacked for SSL madness --brion 2005-12-26
645640 // XXX: *HACK^2* the preg_replace() undoes much of what getInternalURL() does, but we
@@ -647,8 +642,8 @@
648643 $url = preg_replace( '/title=[^&]*&/', '', $titleObj->getInternalURL( $url ) );
649644 }
650645
651 - if( isset( $oldSize ) && isset( $newSize ) ) {
652 - $szdiff = $newSize - $oldSize;
 646+ if( isset( $this->mExtra['oldSize'] ) && isset( $this->mExtra['newSize'] ) ) {
 647+ $szdiff = $this->mExtra['newSize'] - $this->mExtra['oldSize'];
653648 if($szdiff < -500) {
654649 $szdiff = "\002$szdiff\002";
655650 } elseif($szdiff >= 0) {
@@ -659,19 +654,19 @@
660655 $szdiff = '';
661656 }
662657
663 - $user = self::cleanupForIRC( $rc_user_text );
 658+ $user = self::cleanupForIRC( $this->mAttribs['rc_user_text'] );
664659
665 - if( $rc_type == RC_LOG ) {
 660+ if ( $this->mAttribs['rc_type'] == RC_LOG ) {
666661 $targetText = $this->getTitle()->getPrefixedText();
667 - $comment = self::cleanupForIRC( str_replace("[[$targetText]]","[[\00302$targetText\00310]]",$actionComment) );
668 - $flag = $rc_log_action;
 662+ $comment = self::cleanupForIRC( str_replace( "[[$targetText]]", "[[\00302$targetText\00310]]", $this->mExtra['actionComment'] ) );
 663+ $flag = $this->mAttribs['rc_log_action'];
669664 } else {
670 - $comment = self::cleanupForIRC( $rc_comment );
 665+ $comment = self::cleanupForIRC( $this->mAttribs['rc_comment'] );
671666 $flag = '';
672 - if( !$rc_patrolled && ($wgUseRCPatrol || $rc_new && $wgUseNPPatrol) ) {
 667+ if ( !$this->mAttribs['rc_patrolled'] && ( $wgUseRCPatrol || $this->mAttribs['rc_new'] && $wgUseNPPatrol ) ) {
673668 $flag .= '!';
674669 }
675 - $flag .= ($rc_new ? "N" : "") . ($rc_minor ? "M" : "") . ($rc_bot ? "B" : "");
 670+ $flag .= ( $this->mAttribs['rc_new'] ? "N" : "" ) . ( $this->mAttribs['rc_minor'] ? "M" : "" ) . ( $this->mAttribs['rc_bot'] ? "B" : "" );
676671 }
677672
678673 if ( $wgRC2UDPInterwikiPrefix === true && $wgLocalInterwiki !== false ) {

Status & tagging log