Defer some updates in doEditUpdates()
authorAaron Schulz <aschulz@wikimedia.org>
Thu, 21 May 2015 06:13:28 +0000 (23:13 -0700)
committerOri.livneh <ori@wikimedia.org>
Thu, 21 May 2015 19:38:25 +0000 (19:38 +0000)
* 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
includes/page/WikiPage.php

index b430bab..aa210e3 100644 (file)
@@ -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() );
+               }
        }
 
        /**
index 64dd99d..71b3b79 100644 (file)
@@ -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 );
                }
-
        }
 
        /**