(Bug 19725) Do not include suppressed edits in the "View X deleted edits" message...
[lhc/web/wiklou.git] / includes / RecentChange.php
index 81e3b12..8cc5dd7 100644 (file)
@@ -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
  */
 class RecentChange {
        var $mAttribs = array(), $mExtra = array();
-       var $mTitle = false, $mMovedToTitle = false;
+
+       /**
+        * @var Title
+        */
+       var $mTitle = false;
+
+       /**
+        * @var Title
+        */
+       var $mMovedToTitle = false;
        var $numberofWatchingusers = 0 ; # Dummy to prevent error message in SpecialRecentchangeslinked
 
        # Factory methods
@@ -65,7 +75,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 ) {
@@ -114,6 +124,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'] );
@@ -187,7 +201,7 @@ class RecentChange {
                                $editor = ($wgUser->getName() == $this->mAttribs['rc_user_text']) ? 
                                        $wgUser : User::newFromName( $this->mAttribs['rc_user_text'], false );
                        }
-                       # FIXME: this would be better as an extension hook
+                       # @todo FIXME: This would be better as an extension hook
                        $enotif = new EmailNotification();
                        $title = Title::makeTitle( $this->mAttribs['rc_namespace'], $this->mAttribs['rc_title'] );
                        $enotif->notifyOnPageChange( $editor, $title,
@@ -251,7 +265,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
@@ -323,10 +337,26 @@ class RecentChange {
                return $dbw->affectedRows();
        }
 
-       # Makes an entry in the database corresponding to an edit
+       /**
+        * Makes an entry in the database corresponding to an edit
+        *
+        * @param $timestamp
+        * @param $title Title
+        * @param $minor
+        * @param $user User
+        * @param $comment
+        * @param $oldId
+        * @param $lastTimestamp
+        * @param $bot
+        * @param $ip string
+        * @param $oldSize int
+        * @param $newSize int
+        * @param $newId int
+        * @param $patrol int
+        * @return RecentChange
+        */
        public static function notifyEdit( $timestamp, &$title, $minor, &$user, $comment, $oldId,
-               $lastTimestamp, $bot, $ip='', $oldSize=0, $newSize=0, $newId=0, $patrol=0 )
-       {
+               $lastTimestamp, $bot, $ip='', $oldSize=0, $newSize=0, $newId=0, $patrol=0 ) {
                if( !$ip ) {
                        $ip = wfGetIP();
                        if( !$ip ) $ip = '';
@@ -375,10 +405,21 @@ class RecentChange {
         * Makes an entry in the database corresponding to page creation
         * Note: the title object must be loaded with the new id using resetArticleID()
         * @todo Document parameters and return
+        *
+        * @param $timestamp
+        * @param $title Title
+        * @param $minor
+        * @param $user User
+        * @param $comment
+        * @param $bot
+        * @param $ip string
+        * @param $size int
+        * @param $newId int
+        * @param $patrol int
+        * @return RecentChange
         */
        public static function notifyNew( $timestamp, &$title, $minor, &$user, $comment, $bot,
-               $ip='', $size=0, $newId=0, $patrol=0 )
-       {
+               $ip='', $size=0, $newId=0, $patrol=0 ) {
                if( !$ip ) {
                        $ip = wfGetIP();
                        if( !$ip ) $ip = '';
@@ -424,8 +465,19 @@ class RecentChange {
        }
 
        # Makes an entry in the database corresponding to a rename
-       public static function notifyMove( $timestamp, &$oldTitle, &$newTitle, &$user, $comment, $ip='', $overRedir = false )
-       {
+
+       /**
+        * @param $timestamp
+        * @param $oldTitle Title
+        * @param $newTitle Title
+        * @param $user User
+        * @param $comment
+        * @param $ip string
+        * @param $overRedir bool
+        * @return void
+        */
+       public static function notifyMove( $timestamp, &$oldTitle, &$newTitle, &$user, $comment, $ip='',
+               $overRedir = false ) {
                global $wgRequest;
                if( !$ip ) {
                        $ip = wfGetIP();
@@ -491,13 +543,28 @@ class RecentChange {
                return true;
        }
 
+       /**
+        * @param $timestamp
+        * @param $title Title
+        * @param $user User
+        * @param $actionComment
+        * @param $ip string
+        * @param $type
+        * @param $action
+        * @param $target Title
+        * @param $logComment
+        * @param $params
+        * @param $newId int
+        * @return RecentChange
+        */
        public static function newLogEntry( $timestamp, &$title, &$user, $actionComment, $ip='',
-               $type, $action, $target, $logComment, $params, $newId=0 )
-       {
+               $type, $action, $target, $logComment, $params, $newId=0 ) {
                global $wgRequest;
                if( !$ip ) {
                        $ip = wfGetIP();
-                       if( !$ip ) $ip = '';
+                       if( !$ip ) {
+                               $ip = '';
+                       }
                }
 
                $rc = new RecentChange;
@@ -578,7 +645,7 @@ class RecentChange {
        /**
         * Get an attribute value
         *
-        * @param $name Attribute name
+        * @param $name String Attribute name
         * @return mixed
         */
        public function getAttribute( $name ) {
@@ -611,29 +678,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 
@@ -642,8 +704,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) {
@@ -654,22 +716,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;