From: Aaron Schulz Date: Thu, 27 Nov 2008 18:55:47 +0000 (+0000) Subject: Reduce excessive RC write queries X-Git-Tag: 1.31.0-rc.0~44188 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/comptes/?a=commitdiff_plain;h=468ba99c39c3f2ab104f7ffdd8b99db7111695e2;p=lhc%2Fweb%2Fwiklou.git Reduce excessive RC write queries --- diff --git a/includes/Article.php b/includes/Article.php index b9dcc5b51a..07af23523d 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -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(); diff --git a/includes/RecentChange.php b/includes/RecentChange.php index f628fdc95d..10bc318a9c 100644 --- a/includes/RecentChange.php +++ b/includes/RecentChange.php @@ -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,