X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;ds=sidebyside;f=includes%2FRecentChange.php;h=2a5b83152c841623758c768713e65012cf82117b;hb=5c479c9a3daf3c5f88fd17757cf3234ac6d0a940;hp=38c6b74b2afc381ad904a3b778ec15dc359c62f7;hpb=48c3231e32f8486b54c92770d821736019476a36;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/RecentChange.php b/includes/RecentChange.php index 38c6b74b2a..2a5b83152c 100644 --- a/includes/RecentChange.php +++ b/includes/RecentChange.php @@ -2,6 +2,7 @@ /** * Utility class for creating new RC entries + * * mAttribs: * rc_id id of the row in the recentchanges table * rc_timestamp time the entry was made @@ -65,7 +66,7 @@ class RecentChange { /** * Obtain the recent change with a given rc_id value * - * @param $rcid rc_id value to retrieve + * @param $rcid Int rc_id value to retrieve * @return RecentChange */ public static function newFromId( $rcid ) { @@ -73,7 +74,6 @@ class RecentChange { $res = $dbr->select( 'recentchanges', '*', array( 'rc_id' => $rcid ), __METHOD__ ); if( $res && $dbr->numRows( $res ) > 0 ) { $row = $dbr->fetchObject( $res ); - $dbr->freeResult( $res ); return self::newFromRow( $row ); } else { return null; @@ -115,6 +115,10 @@ class RecentChange { $this->mExtra = $extra; } + /** + * + * @return Title + */ public function &getTitle() { if( $this->mTitle === false ) { $this->mTitle = Title::makeTitle( $this->mAttribs['rc_namespace'], $this->mAttribs['rc_title'] ); @@ -252,7 +256,7 @@ class RecentChange { * * @param $change Mixed: RecentChange or corresponding rc_id * @param $auto Boolean: for automatic patrol - * @return See doMarkPatrolled(), or null if $change is not an existing rc_id + * @return Array See doMarkPatrolled(), or null if $change is not an existing rc_id */ public static function markPatrolled( $change, $auto = false ) { $change = $change instanceof RecentChange @@ -579,7 +583,7 @@ class RecentChange { /** * Get an attribute value * - * @param $name Attribute name + * @param $name String Attribute name * @return mixed */ public function getAttribute( $name ) { @@ -612,29 +616,24 @@ class RecentChange { public function getIRCLine() { global $wgUseRCPatrol, $wgUseNPPatrol, $wgRC2UDPInterwikiPrefix, $wgLocalInterwiki; - // 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); - - if( $rc_type == RC_LOG ) { - $titleObj = Title::newFromText( "Log/$rc_log_type", NS_SPECIAL ); + if( $this->mAttribs['rc_type'] == RC_LOG ) { + $titleObj = Title::newFromText( 'Log/' . $this->mAttribs['rc_log_type'], NS_SPECIAL ); } else { $titleObj =& $this->getTitle(); } $title = $titleObj->getPrefixedText(); $title = self::cleanupForIRC( $title ); - if( $rc_type == RC_LOG ) { + if( $this->mAttribs['rc_type'] == RC_LOG ) { $url = ''; } else { - if( $rc_type == RC_NEW ) { - $url = "oldid=$rc_this_oldid"; + if( $this->mAttribs['rc_type'] == RC_NEW ) { + $url = 'oldid=' . $this->mAttribs['rc_this_oldid']; } else { - $url = "diff=$rc_this_oldid&oldid=$rc_last_oldid"; + $url = 'diff=' . $this->mAttribs['rc_this_oldid'] . '&oldid=' . $this->mAttribs['rc_last_oldid']; } - if( $wgUseRCPatrol || ($rc_type == RC_NEW && $wgUseNPPatrol) ) { - $url .= "&rcid=$rc_id"; + if ( $wgUseRCPatrol || ( $this->mAttribs['rc_type'] == RC_NEW && $wgUseNPPatrol ) ) { + $url .= '&rcid=' . $this->mAttribs['rc_id']; } // XXX: *HACK* this should use getFullURL(), hacked for SSL madness --brion 2005-12-26 // XXX: *HACK^2* the preg_replace() undoes much of what getInternalURL() does, but we @@ -643,8 +642,8 @@ class RecentChange { $url = preg_replace( '/title=[^&]*&/', '', $titleObj->getInternalURL( $url ) ); } - if( isset( $oldSize ) && isset( $newSize ) ) { - $szdiff = $newSize - $oldSize; + if( isset( $this->mExtra['oldSize'] ) && isset( $this->mExtra['newSize'] ) ) { + $szdiff = $this->mExtra['newSize'] - $this->mExtra['oldSize']; if($szdiff < -500) { $szdiff = "\002$szdiff\002"; } elseif($szdiff >= 0) { @@ -655,22 +654,22 @@ class RecentChange { $szdiff = ''; } - $user = self::cleanupForIRC( $rc_user_text ); + $user = self::cleanupForIRC( $this->mAttribs['rc_user_text'] ); - if( $rc_type == RC_LOG ) { + if ( $this->mAttribs['rc_type'] == RC_LOG ) { $targetText = $this->getTitle()->getPrefixedText(); - $comment = self::cleanupForIRC( str_replace("[[$targetText]]","[[\00302$targetText\00310]]",$actionComment) ); - $flag = $rc_log_action; + $comment = self::cleanupForIRC( str_replace( "[[$targetText]]", "[[\00302$targetText\00310]]", $this->mExtra['actionComment'] ) ); + $flag = $this->mAttribs['rc_log_action']; } else { - $comment = self::cleanupForIRC( $rc_comment ); + $comment = self::cleanupForIRC( $this->mAttribs['rc_comment'] ); $flag = ''; - if( !$rc_patrolled && ($wgUseRCPatrol || $rc_new && $wgUseNPPatrol) ) { + if ( !$this->mAttribs['rc_patrolled'] && ( $wgUseRCPatrol || $this->mAttribs['rc_new'] && $wgUseNPPatrol ) ) { $flag .= '!'; } - $flag .= ($rc_new ? "N" : "") . ($rc_minor ? "M" : "") . ($rc_bot ? "B" : ""); + $flag .= ( $this->mAttribs['rc_new'] ? "N" : "" ) . ( $this->mAttribs['rc_minor'] ? "M" : "" ) . ( $this->mAttribs['rc_bot'] ? "B" : "" ); } - if ( $wgRC2UDPInterwikiPrefix === true ) { + if ( $wgRC2UDPInterwikiPrefix === true && $wgLocalInterwiki !== false ) { $prefix = $wgLocalInterwiki; } elseif ( $wgRC2UDPInterwikiPrefix ) { $prefix = $wgRC2UDPInterwikiPrefix;