X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fchanges%2FRecentChange.php;h=9025736c69684bf9ad3034ce1ef96c6174321c0a;hb=682e2b9c6b7c439fe5ba0be083f0479af95e1db3;hp=60c9182ba04c7fee9367a15af8d28d996d26cdd7;hpb=280ce0936126fa3a3bf17ebe02fa37cf2116cd41;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/changes/RecentChange.php b/includes/changes/RecentChange.php index 60c9182ba0..9025736c69 100644 --- a/includes/changes/RecentChange.php +++ b/includes/changes/RecentChange.php @@ -67,6 +67,7 @@ class RecentChange { const SRC_NEW = 'mw.new'; const SRC_LOG = 'mw.log'; const SRC_EXTERNAL = 'mw.external'; // obsolete + const SRC_CATEGORIZE = 'mw.categorize'; public $mAttribs = array(); public $mExtra = array(); @@ -97,6 +98,7 @@ class RecentChange { 'new' => RC_NEW, 'log' => RC_LOG, 'external' => RC_EXTERNAL, + 'categorize' => RC_CATEGORIZE, ); # Factory methods @@ -171,11 +173,17 @@ class RecentChange { * * @param array $conds Array of conditions * @param mixed $fname Override the method name in profiling/logs + * @param int $dbType DB_* constant + * * @return RecentChange|null */ - public static function newFromConds( $conds, $fname = __METHOD__ ) { - $dbr = wfGetDB( DB_SLAVE ); - $row = $dbr->selectRow( 'recentchanges', self::selectFields(), $conds, $fname ); + public static function newFromConds( + $conds, + $fname = __METHOD__, + $dbType = DB_SLAVE + ) { + $db = wfGetDB( $dbType ); + $row = $db->selectRow( 'recentchanges', self::selectFields(), $conds, $fname ); if ( $row !== false ) { return self::newFromRow( $row ); } else { @@ -316,15 +324,21 @@ class RecentChange { $editor = $this->getPerformer(); $title = $this->getTitle(); - if ( Hooks::run( 'AbortEmailNotification', array( $editor, $title, $this ) ) ) { - # @todo FIXME: This would be better as an extension hook - $enotif = new EmailNotification(); - $enotif->notifyOnPageChange( $editor, $title, - $this->mAttribs['rc_timestamp'], - $this->mAttribs['rc_comment'], - $this->mAttribs['rc_minor'], - $this->mAttribs['rc_last_oldid'], - $this->mExtra['pageStatus'] ); + // Never send an RC notification email about categorization changes + if ( $this->mAttribs['rc_type'] != RC_CATEGORIZE ) { + if ( Hooks::run( 'AbortEmailNotification', array( $editor, $title, $this ) ) ) { + # @todo FIXME: This would be better as an extension hook + $enotif = new EmailNotification(); + $enotif->notifyOnPageChange( + $editor, + $title, + $this->mAttribs['rc_timestamp'], + $this->mAttribs['rc_comment'], + $this->mAttribs['rc_minor'], + $this->mAttribs['rc_last_oldid'], + $this->mExtra['pageStatus'] + ); + } } } @@ -452,7 +466,9 @@ class RecentChange { // Automatic patrol needs "autopatrol", ordinary patrol needs "patrol" $right = $auto ? 'autopatrol' : 'patrol'; $errors = array_merge( $errors, $this->getTitle()->getUserPermissionsErrors( $right, $user ) ); - if ( !Hooks::run( 'MarkPatrolled', array( $this->getAttribute( 'rc_id' ), &$user, false ) ) ) { + if ( !Hooks::run( 'MarkPatrolled', + array( $this->getAttribute( 'rc_id' ), &$user, false, $auto ) ) + ) { $errors[] = array( 'hookaborted' ); } // Users without the 'autopatrol' right can't patrol their @@ -473,7 +489,10 @@ class RecentChange { $this->reallyMarkPatrolled(); // Log this patrol event PatrolLog::record( $this, $auto, $user ); - Hooks::run( 'MarkPatrolledComplete', array( $this->getAttribute( 'rc_id' ), &$user, false ) ); + Hooks::run( + 'MarkPatrolledComplete', + array( $this->getAttribute( 'rc_id' ), &$user, false, $auto ) + ); return array(); } @@ -748,6 +767,80 @@ class RecentChange { return $rc; } + /** + * Constructs a RecentChange object for the given categorization + * This does not call save() on the object and thus does not write to the db + * + * @since 1.27 + * + * @param string $timestamp Timestamp of the recent change to occur + * @param Title $categoryTitle Title of the category a page is being added to or removed from + * @param User $user User object of the user that made the change + * @param string $comment Change summary + * @param Title $pageTitle Title of the page that is being added or removed + * @param int $oldRevId Parent revision ID of this change + * @param int $newRevId Revision ID of this change + * @param string $lastTimestamp Parent revision timestamp of this change + * @param bool $bot true, if the change was made by a bot + * @param string $ip IP address of the user, if the change was made anonymously + * @param int $deleted Indicates whether the change has been deleted + * + * @return RecentChange + */ + public static function newForCategorization( + $timestamp, + Title $categoryTitle, + User $user = null, + $comment, + Title $pageTitle, + $oldRevId, + $newRevId, + $lastTimestamp, + $bot, + $ip = '', + $deleted = 0 + ) { + + $rc = new RecentChange; + $rc->mTitle = $categoryTitle; + $rc->mPerformer = $user; + $rc->mAttribs = array( + 'rc_timestamp' => $timestamp, + 'rc_namespace' => $categoryTitle->getNamespace(), + 'rc_title' => $categoryTitle->getDBkey(), + 'rc_type' => RC_CATEGORIZE, + 'rc_source' => self::SRC_CATEGORIZE, + 'rc_minor' => 0, + 'rc_cur_id' => $pageTitle->getArticleID(), + 'rc_user' => $user ? $user->getId() : 0, + 'rc_user_text' => $user ? $user->getName() : '', + 'rc_comment' => $comment, + 'rc_this_oldid' => $newRevId, + 'rc_last_oldid' => $oldRevId, + 'rc_bot' => $bot ? 1 : 0, + 'rc_ip' => self::checkIPAddress( $ip ), + 'rc_patrolled' => 1, // Always patrolled, just like log entries + 'rc_new' => 0, # obsolete + 'rc_old_len' => 0, + 'rc_new_len' => 0, + 'rc_deleted' => $deleted, + 'rc_logid' => 0, + 'rc_log_type' => null, + 'rc_log_action' => '', + 'rc_params' => '' + ); + + $rc->mExtra = array( + 'prefixedDBkey' => $categoryTitle->getPrefixedDBkey(), + 'lastTimestamp' => $lastTimestamp, + 'oldSize' => 0, + 'newSize' => 0, + 'pageStatus' => 'changed' + ); + + return $rc; + } + /** * Initialises the members of this object from a mysql row object * @@ -868,3 +961,4 @@ class RecentChange { return $unserializedParams; } } +