X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FRecentChange.php;h=4a7bafd9006b41cc25aea961d3e8fabff618d750;hb=125d6d5feceba4d3d740efb5be0be83058546a20;hp=20e7909a2a23b98abad205958be2d88a5cd0890e;hpb=057563b96ac833c195150d72cffbdcf71b1660af;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/RecentChange.php b/includes/RecentChange.php index 20e7909a2a..4a7bafd900 100644 --- a/includes/RecentChange.php +++ b/includes/RecentChange.php @@ -70,6 +70,11 @@ class RecentChange { */ var $mTitle = false; + /** + * @var User + */ + private $mPerformer = false; + /** * @var Title */ @@ -168,12 +173,28 @@ class RecentChange { return $this->mMovedToTitle; } + /** + * Get the User object of the person who performed this change. + * + * @return User + */ + public function getPerformer() { + if ( $this->mPerformer === false ) { + if ( $this->mAttribs['rc_user'] ) { + $this->mPerformer = User::newFromID( $this->mAttribs['rc_user'] ); + } else { + $this->mPerformer = User::newFromName( $this->mAttribs['rc_user_text'], false ); + } + } + return $this->mPerformer; + } + /** * Writes the data in this object to the database * @param $noudp bool */ public function save( $noudp = false ) { - global $wgLocalInterwiki, $wgPutIPinRC, $wgContLang; + global $wgLocalInterwiki, $wgPutIPinRC, $wgUseEnotif, $wgShowUpdatedMarker, $wgContLang; $dbw = wfGetDB( DB_MASTER ); if( !is_array($this->mExtra) ) { @@ -218,18 +239,9 @@ class RecentChange { } # E-mail notifications - global $wgUseEnotif, $wgShowUpdatedMarker, $wgUser; if( $wgUseEnotif || $wgShowUpdatedMarker ) { - // Users - if( $this->mAttribs['rc_user'] ) { - $editor = ($wgUser->getId() == $this->mAttribs['rc_user']) ? - $wgUser : User::newFromID( $this->mAttribs['rc_user'] ); - // Anons - } else { - $editor = ($wgUser->getName() == $this->mAttribs['rc_user_text']) ? - $wgUser : User::newFromName( $this->mAttribs['rc_user_text'], false ); - } - $title = Title::makeTitle( $this->mAttribs['rc_namespace'], $this->mAttribs['rc_title'] ); + $editor = $this->getPerformer(); + $title = $this->getTitle(); if ( wfRunHooks( 'AbortEmailNotification', array($editor, $title) ) ) { # @todo FIXME: This would be better as an extension hook @@ -393,6 +405,8 @@ class RecentChange { public static function notifyEdit( $timestamp, &$title, $minor, &$user, $comment, $oldId, $lastTimestamp, $bot, $ip='', $oldSize=0, $newSize=0, $newId=0, $patrol=0 ) { $rc = new RecentChange; + $rc->mTitle = $title; + $rc->mPerformer = $user; $rc->mAttribs = array( 'rc_timestamp' => $timestamp, 'rc_cur_time' => $timestamp, @@ -451,6 +465,8 @@ class RecentChange { public static function notifyNew( $timestamp, &$title, $minor, &$user, $comment, $bot, $ip='', $size=0, $newId=0, $patrol=0 ) { $rc = new RecentChange; + $rc->mTitle = $title; + $rc->mPerformer = $user; $rc->mAttribs = array( 'rc_timestamp' => $timestamp, 'rc_cur_time' => $timestamp, @@ -538,6 +554,8 @@ class RecentChange { global $wgRequest; $rc = new RecentChange; + $rc->mTitle = $target; + $rc->mPerformer = $user; $rc->mAttribs = array( 'rc_timestamp' => $timestamp, 'rc_cur_time' => $timestamp,