*/
/**
- * Abstract class for type hinting (accepts WikiPage, Article, ImagePage, CategoryPage)
+ * Interface for type hinting (accepts WikiPage, Article, ImagePage, CategoryPage)
*/
interface Page {
}
$changed = !$content->equals( $oldContent );
+ $dbw = wfGetDB( DB_MASTER );
+
if ( $changed ) {
$prepStatus = $content->prepareSave( $this, $flags, $oldid, $user );
$status->merge( $prepStatus );
return $status;
}
- $dbw = wfGetDB( DB_MASTER );
- $dbw->begin( __METHOD__ );
+ $dbw->startAtomic( __METHOD__ );
// Get the latest page_latest value while locking it.
// Do a CAS style check to see if it's the same as when this method
// started. If it changed then bail out before touching the DB.
$latestNow = $this->lockAndGetLatest();
if ( $latestNow != $oldid ) {
- $dbw->commit( __METHOD__ );
+ $dbw->endAtomic( __METHOD__ );
// Page updated or deleted in the mean time
$status->fatal( 'edit-conflict' );
$user->incEditCount();
- $dbw->commit( __METHOD__ );
+ $dbw->endAtomic( __METHOD__ );
$this->mTimestamp = $now;
} else {
// Bug 32948: revision ID must be set to page {{REVISIONID}} and
$revision->setId( $this->getLatest() );
}
- // Update links tables, site stats, etc.
- $this->doEditUpdates(
- $revision,
- $user,
- array(
- 'changed' => $changed,
- 'oldcountable' => $meta['oldCountable'],
- 'oldrevision' => $meta['oldRevision']
- )
- );
-
if ( $changed ) {
// Return the new revision to the caller
$status->value['revision'] = $revision;
$this->mTitle->invalidateCache( $now );
}
- // Trigger post-save hook
- $hook_args = array( &$this, &$user, $content, $summary,
- $flags & EDIT_MINOR, null, null, &$flags, $revision, &$status, $meta['baseRevId'] );
- ContentHandler::runLegacyHooks( 'ArticleSaveComplete', $hook_args );
- Hooks::run( 'PageContentSaveComplete', $hook_args );
+ // Do secondary updates once the main changes have been committed...
+ $that = $this;
+ $dbw->onTransactionIdle(
+ function () use (
+ $dbw, &$that, $revision, &$user, $content, $summary, &$flags,
+ $changed, $meta, &$status
+ ) {
+ // Do per-page updates in a transaction
+ $dbw->setFlag( DBO_TRX );
+ // Update links tables, site stats, etc.
+ $that->doEditUpdates(
+ $revision,
+ $user,
+ array(
+ 'changed' => $changed,
+ 'oldcountable' => $meta['oldCountable'],
+ 'oldrevision' => $meta['oldRevision']
+ )
+ );
+ // Trigger post-save hook
+ $params = array( &$that, &$user, $content, $summary, $flags & EDIT_MINOR,
+ null, null, &$flags, $revision, &$status, $meta['baseRevId'] );
+ ContentHandler::runLegacyHooks( 'ArticleSaveComplete', $params );
+ Hooks::run( 'PageContentSaveComplete', $params );
+ }
+ );
return $status;
}