From 072e3666d3fcd1738d4742930bbe3acd5e7519b2 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Wed, 20 May 2015 23:13:28 -0700 Subject: [PATCH] Defer some updates in doEditUpdates() * These updates add to editing time and can be done after sending the HTTP response for performance * Also improved the active users job insertion logic Change-Id: I5b25217c4f08db7fa9a05eac046283f02d45865e --- includes/changes/RecentChange.php | 5 +++++ includes/page/WikiPage.php | 12 +++++------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/includes/changes/RecentChange.php b/includes/changes/RecentChange.php index b430bab91c..aa210e3bcd 100644 --- a/includes/changes/RecentChange.php +++ b/includes/changes/RecentChange.php @@ -332,6 +332,11 @@ class RecentChange { $this->mExtra['pageStatus'] ); } } + + // Update the cached list of active users + if ( $this->mAttribs['rc_user'] > 0 ) { + JobQueueGroup::singleton()->lazyPush( RecentChangesUpdateJob::newCacheUpdateJob() ); + } } /** diff --git a/includes/page/WikiPage.php b/includes/page/WikiPage.php index 64dd99d7ea..71b3b7936f 100644 --- a/includes/page/WikiPage.php +++ b/includes/page/WikiPage.php @@ -1836,6 +1836,7 @@ class WikiPage implements Page, IDBAccessObject { // Mark as patrolled if the user can do so $patrolled = $wgUseRCPatrol && !count( $this->mTitle->getUserPermissionsErrors( 'autopatrol', $user ) ); + // Add RC row to the DB $rc = RecentChange::notifyEdit( $now, $this->mTitle, $isminor, $user, $summary, $oldid, $this->getTimestamp(), $bot, '', $oldsize, $newsize, @@ -2193,20 +2194,18 @@ class WikiPage implements Page, IDBAccessObject { $recursive = $options['changed']; // bug 50785 $updates = $content->getSecondaryDataUpdates( $this->getTitle(), null, $recursive, $editInfo->output ); - DataUpdate::runUpdates( $updates ); + foreach ( $updates as $update ) { + DeferredUpdates::addUpdate( $update ); + } } Hooks::run( 'ArticleEditUpdates', array( &$this, &$editInfo, $options['changed'] ) ); if ( Hooks::run( 'ArticleEditUpdatesDeleteFromRecentchanges', array( &$this ) ) ) { - // Update the cached list of active users - $jobs = array( RecentChangesUpdateJob::newCacheUpdateJob() ); // Flush old entries from the `recentchanges` table if ( mt_rand( 0, 9 ) == 0 ) { - $jobs[] = RecentChangesUpdateJob::newPurgeJob(); + JobQueueGroup::singleton()->lazyPush( RecentChangesUpdateJob::newPurgeJob() ); } - - JobQueueGroup::singleton()->lazyPush( $jobs ); } if ( !$this->exists() ) { @@ -2275,7 +2274,6 @@ class WikiPage implements Page, IDBAccessObject { } elseif ( $options['changed'] ) { // bug 50785 self::onArticleEdit( $this->mTitle ); } - } /** -- 2.20.1