Merge "Enable users to watch category membership changes #2"
[lhc/web/wiklou.git] / includes / changes / RecentChange.php
index b681f7f..9025736 100644 (file)
@@ -173,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 {
@@ -318,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']
+                                       );
+                               }
                        }
                }
 
@@ -454,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
@@ -475,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();
        }
@@ -754,7 +771,7 @@ class RecentChange {
         * 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.26
+        * @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
@@ -944,3 +961,4 @@ class RecentChange {
                return $unserializedParams;
        }
 }
+