Moved contribs rev parent ID batch query into doBatchLookups()
[lhc/web/wiklou.git] / includes / RecentChange.php
index a2b9796..d59f1aa 100644 (file)
@@ -299,7 +299,7 @@ class RecentChange {
                // Automatic patrol needs "autopatrol", ordinary patrol needs "patrol"
                $right = $auto ? 'autopatrol' : 'patrol';
                $errors = array_merge( $errors, $this->getTitle()->getUserPermissionsErrors( $right, $user ) );
-               if( !wfRunHooks('MarkPatrolled', array($this->getAttribute('rc_id'), &$wgUser, false)) ) {
+               if( !wfRunHooks('MarkPatrolled', array($this->getAttribute('rc_id'), &$user, false)) ) {
                        $errors[] = array('hookaborted');
                }
                // Users without the 'autopatrol' right can't patrol their
@@ -361,8 +361,9 @@ class RecentChange {
         */
        public static function notifyEdit( $timestamp, &$title, $minor, &$user, $comment, $oldId,
                $lastTimestamp, $bot, $ip='', $oldSize=0, $newSize=0, $newId=0, $patrol=0 ) {
+               global $wgRequest;
                if( !$ip ) {
-                       $ip = wfGetIP();
+                       $ip = $wgRequest->getIP();
                        if( !$ip ) $ip = '';
                }
 
@@ -424,8 +425,9 @@ class RecentChange {
         */
        public static function notifyNew( $timestamp, &$title, $minor, &$user, $comment, $bot,
                $ip='', $size=0, $newId=0, $patrol=0 ) {
+               global $wgRequest;
                if( !$ip ) {
-                       $ip = wfGetIP();
+                       $ip = $wgRequest->getIP();
                        if( !$ip ) $ip = '';
                }
 
@@ -465,72 +467,7 @@ class RecentChange {
                        'newSize' => $size
                );
                $rc->save();
-               return $rc;     
-       }
-
-       # Makes an entry in the database corresponding to a rename
-
-       /**
-        * @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();
-                       if( !$ip ) $ip = '';
-               }
-
-               $rc = new RecentChange;
-               $rc->mAttribs = array(
-                       'rc_timestamp'  => $timestamp,
-                       'rc_cur_time'   => $timestamp,
-                       'rc_namespace'  => $oldTitle->getNamespace(),
-                       'rc_title'      => $oldTitle->getDBkey(),
-                       'rc_type'       => $overRedir ? RC_MOVE_OVER_REDIRECT : RC_MOVE,
-                       'rc_minor'      => 0,
-                       'rc_cur_id'     => $oldTitle->getArticleID(),
-                       'rc_user'       => $user->getId(),
-                       'rc_user_text'  => $user->getName(),
-                       'rc_comment'    => $comment,
-                       'rc_this_oldid' => 0,
-                       'rc_last_oldid' => 0,
-                       'rc_bot'        => $user->isAllowed( 'bot' ) ? $wgRequest->getBool( 'bot' , true ) : 0,
-                       'rc_moved_to_ns' => $newTitle->getNamespace(),
-                       'rc_moved_to_title' => $newTitle->getDBkey(),
-                       'rc_ip'         => $ip,
-                       'rc_new'        => 0, # obsolete
-                       'rc_patrolled'  => 1,
-                       'rc_old_len'    => null,
-                       'rc_new_len'    => null,
-                       'rc_deleted'    => 0,
-                       'rc_logid'      => 0, # notifyMove not used anymore
-                       'rc_log_type'   => null,
-                       'rc_log_action' => '',
-                       'rc_params'     => ''
-               );
-
-               $rc->mExtra = array(
-                       'prefixedDBkey' => $oldTitle->getPrefixedDBkey(),
-                       'lastTimestamp' => 0,
-                       'prefixedMoveTo' => $newTitle->getPrefixedDBkey()
-               );
-               $rc->save();
-       }
-
-       public static function notifyMoveToNew( $timestamp, &$oldTitle, &$newTitle, &$user, $comment, $ip='' ) {
-               RecentChange::notifyMove( $timestamp, $oldTitle, $newTitle, $user, $comment, $ip, false );
-       }
-
-       public static function notifyMoveOverRedirect( $timestamp, &$oldTitle, &$newTitle, &$user, $comment, $ip='' ) {
-               RecentChange::notifyMove( $timestamp, $oldTitle, $newTitle, $user, $comment, $ip, true );
+               return $rc;
        }
 
        public static function notifyLog( $timestamp, &$title, &$user, $actionComment, $ip='', $type, 
@@ -565,7 +502,7 @@ class RecentChange {
                $type, $action, $target, $logComment, $params, $newId=0 ) {
                global $wgRequest;
                if( !$ip ) {
-                       $ip = wfGetIP();
+                       $ip = $wgRequest->getIP();
                        if( !$ip ) {
                                $ip = '';
                        }
@@ -680,10 +617,11 @@ class RecentChange {
        }
 
        public function getIRCLine() {
-               global $wgUseRCPatrol, $wgUseNPPatrol, $wgRC2UDPInterwikiPrefix, $wgLocalInterwiki;
+               global $wgUseRCPatrol, $wgUseNPPatrol, $wgRC2UDPInterwikiPrefix, $wgLocalInterwiki,
+                       $wgCanonicalServer, $wgScript;
 
                if( $this->mAttribs['rc_type'] == RC_LOG ) {
-                       $titleObj = Title::newFromText( 'Log/' . $this->mAttribs['rc_log_type'], NS_SPECIAL );
+                       $titleObj = SpecialPage::getTitleFor( 'Log', $this->mAttribs['rc_log_type'] );
                } else {
                        $titleObj =& $this->getTitle();
                }
@@ -693,23 +631,22 @@ class RecentChange {
                if( $this->mAttribs['rc_type'] == RC_LOG ) {
                        $url = '';
                } else {
+                       $url = $wgCanonicalServer . $wgScript;
                        if( $this->mAttribs['rc_type'] == RC_NEW ) {
-                               $url = 'oldid=' . $this->mAttribs['rc_this_oldid'];
+                               $query = '?oldid=' . $this->mAttribs['rc_this_oldid'];
                        } else {
-                               $url = 'diff=' . $this->mAttribs['rc_this_oldid'] . '&oldid=' . $this->mAttribs['rc_last_oldid'];
+                               $query = '?diff=' . $this->mAttribs['rc_this_oldid'] . '&oldid=' . $this->mAttribs['rc_last_oldid'];
                        }
                        if ( $wgUseRCPatrol || ( $this->mAttribs['rc_type'] == RC_NEW && $wgUseNPPatrol ) ) {
-                               $url .= '&rcid=' . $this->mAttribs['rc_id'];
+                               $query .= '&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 
-                       // XXX: need to call it so that URL paths on the Wikimedia secure server can be fixed
-                       // XXX: by a custom GetInternalURL hook --vyznev 2008-12-10
-                       $url = preg_replace( '/title=[^&]*&/', '', $titleObj->getInternalURL( $url ) );
+                       // HACK: We need this hook for WMF's secure server setup
+                       wfRunHooks( 'IRCLineURL', array( &$url, &$query ) );
+                       $url .= $query;
                }
 
-               if( isset( $this->mExtra['oldSize'] ) && isset( $this->mExtra['newSize'] ) ) {
-                       $szdiff = $this->mExtra['newSize'] - $this->mExtra['oldSize'];
+               if( $this->mAttribs['rc_old_len'] !== null && $this->mAttribs['rc_new_len'] !== null ) {
+                       $szdiff = $this->mAttribs['rc_new_len'] - $this->mAttribs['rc_old_len'];
                        if($szdiff < -500) {
                                $szdiff = "\002$szdiff\002";
                        } elseif($szdiff >= 0) {