Defer addAutopromoteOnceGroups to transaction idle
authorAaron Schulz <aschulz@wikimedia.org>
Thu, 10 Jul 2014 18:22:03 +0000 (11:22 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Thu, 10 Jul 2014 18:22:03 +0000 (11:22 -0700)
* Extension callbacks in that method can be slow and show up in
  dbperformance.log sometimes.

Change-Id: Idc30c29826e18c4e3287b06d4ce7bae72602e0ea

includes/page/WikiPage.php

index 7c412ea..2ff72fd 100644 (file)
@@ -2047,7 +2047,9 @@ class WikiPage implements Page, IDBAccessObject {
                wfRunHooks( 'PageContentSaveComplete', $hook_args );
 
                // Promote user to any groups they meet the criteria for
-               $user->addAutopromoteOnceGroups( 'onEdit' );
+               $dbw->onTransactionIdle( function() use ( $user ) {
+                       $user->addAutopromoteOnceGroups( 'onEdit' );
+               } );
 
                wfProfileOut( __METHOD__ );
                return $status;