From 8065f529967783a3fb0b22c99e5b9016c0b619bc Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Wed, 8 Apr 2015 10:33:58 -0700 Subject: [PATCH] Made WikiPage::doPurge() avoid calling commit() * Calling commit() can cause imbalanced begin/commit problems Change-Id: I55fec065de20653b216c8dfac7c361124c8fe10a --- includes/page/WikiPage.php | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/includes/page/WikiPage.php b/includes/page/WikiPage.php index 5caffaba14..6242a548a8 100644 --- a/includes/page/WikiPage.php +++ b/includes/page/WikiPage.php @@ -1150,28 +1150,24 @@ class WikiPage implements Page, IDBAccessObject { * @return bool */ public function doPurge() { - global $wgUseSquid; - if ( !Hooks::run( 'ArticlePurge', array( &$this ) ) ) { return false; } - // Invalidate the cache - $this->mTitle->invalidateCache(); - - if ( $wgUseSquid ) { - // Commit the transaction before the purge is sent - $dbw = wfGetDB( DB_MASTER ); - $dbw->commit( __METHOD__ ); - - // Send purge - $update = SquidUpdate::newSimplePurge( $this->mTitle ); - $update->doUpdate(); - } + $title = $this->mTitle; + wfGetDB( DB_MASTER )->onTransactionIdle( function() use ( $title ) { + global $wgUseSquid; + // Invalidate the cache in auto-commit mode + $title->invalidateCache(); + if ( $wgUseSquid ) { + // Send purge now that page_touched update was committed above + $update = SquidUpdate::newSimplePurge( $title ); + $update->doUpdate(); + } + } ); if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) { // @todo move this logic to MessageCache - if ( $this->exists() ) { // NOTE: use transclusion text for messages. // This is consistent with MessageCache::getMsgFromNamespace() @@ -1188,6 +1184,7 @@ class WikiPage implements Page, IDBAccessObject { MessageCache::singleton()->replace( $this->mTitle->getDBkey(), $text ); } + return true; } -- 2.20.1