Reduce excessive RC write queries
authorAaron Schulz <aaron@users.mediawiki.org>
Thu, 27 Nov 2008 18:55:47 +0000 (18:55 +0000)
committerAaron Schulz <aaron@users.mediawiki.org>
Thu, 27 Nov 2008 18:55:47 +0000 (18:55 +0000)
includes/Article.php
includes/RecentChange.php

index b9dcc5b..07af235 100644 (file)
@@ -1556,17 +1556,20 @@ class Article {
                                        $revisionId = 0;
                                        $dbw->rollback();
                                } else {
+                                       global $wgUseRCPatrol;
                                        wfRunHooks( 'NewRevisionFromEditComplete', array($this, $revision, $baseRevId, $user) );
-
                                        # Update recentchanges
                                        if( !( $flags & EDIT_SUPPRESS_RC ) ) {
+                                               # Mark as patrolled if the user can do so
+                                               $patrolled = $wgUseRCPatrol && $user->isAllowed('autopatrol');
+                                               # Add RC row to the DB
                                                $rc = RecentChange::notifyEdit( $now, $this->mTitle, $isminor, $user, $summary,
                                                        $this->mLatest, $this->getTimestamp(), $bot, '', $oldsize, $newsize,
-                                                       $revisionId );
-
-                                               # Mark as patrolled if the user can do so
-                                               if( $GLOBALS['wgUseRCPatrol'] && $user->isAllowed( 'autopatrol' ) ) {
-                                                       RecentChange::markPatrolled( $rc, true );
+                                                       $revisionId, $patrolled
+                                               );
+                                               # Log auto-patrolled edits
+                                               if( $patrolled ) {
+                                                       PatrolLog::record( $rc, true );
                                                }
                                        }
                                        $user->incEditCount();
@@ -1636,13 +1639,17 @@ class Article {
                        $this->updateRevisionOn( $dbw, $revision, 0 );
 
                        wfRunHooks( 'NewRevisionFromEditComplete', array($this, $revision, false, $user) );
-
+                       # Update recentchanges
                        if( !( $flags & EDIT_SUPPRESS_RC ) ) {
+                               global $wgUseRCPatrol, $wgUseNPPatrol;
+                               # Mark as patrolled if the user can do so
+                               $patrolled = ($wgUseRCPatrol || $wgUseNPPatrol) && $user->isAllowed('autopatrol');
+                               # Add RC row to the DB
                                $rc = RecentChange::notifyNew( $now, $this->mTitle, $isminor, $user, $summary, $bot,
-                                 '', strlen( $text ), $revisionId );
-                               # Mark as patrolled if the user can
-                               if( ($GLOBALS['wgUseRCPatrol'] || $GLOBALS['wgUseNPPatrol']) && $user->isAllowed( 'autopatrol' ) ) {
-                                       RecentChange::markPatrolled( $rc, true );
+                                       '', strlen($text), $revisionId, $patrolled );
+                               # Log auto-patrolled edits
+                               if( $patrolled ) {
+                                       PatrolLog::record( $rc, true );
                                }
                        }
                        $user->incEditCount();
index f628fdc..10bc318 100644 (file)
@@ -310,8 +310,8 @@ class RecentChange
        }
 
        # Makes an entry in the database corresponding to an edit
-       public static function notifyEdit( $timestamp, &$title, $minor, &$user, $comment,
-               $oldId, $lastTimestamp, $bot, $ip = '', $oldSize = 0, $newSize = 0, $newId = 0)
+       public static function notifyEdit( $timestamp, &$title, $minor, &$user, $comment, $oldId,
+               $lastTimestamp, $bot, $ip='', $oldSize=0, $newSize=0, $newId=0, $patrol=0 )
        {
                if( !$ip ) {
                        $ip = wfGetIP();
@@ -338,7 +338,7 @@ class RecentChange
                        'rc_moved_to_ns'        => 0,
                        'rc_moved_to_title'     => '',
                        'rc_ip'         => $ip,
-                       'rc_patrolled'  => 0,
+                       'rc_patrolled'  => intval($patrol),
                        'rc_new'        => 0,  # obsolete
                        'rc_old_len'    => $oldSize,
                        'rc_new_len'    => $newSize,
@@ -365,7 +365,7 @@ class RecentChange
         * @todo Document parameters and return
         */
        public static function notifyNew( $timestamp, &$title, $minor, &$user, $comment, $bot,
-         $ip='', $size = 0, $newId = 0 )
+               $ip='', $size=0, $newId=0, $patrol=0 )
        {
                if( !$ip ) {
                        $ip = wfGetIP();
@@ -392,7 +392,7 @@ class RecentChange
                        'rc_moved_to_ns'    => 0,
                        'rc_moved_to_title' => '',
                        'rc_ip'             => $ip,
-                       'rc_patrolled'      => 0,
+                       'rc_patrolled'      => intval($patrol),
                        'rc_new'                => 1, # obsolete
                        'rc_old_len'        => 0,
                        'rc_new_len'        => $size,