From e3e201e75dbf17b6a5601491d8d5714bc73b33fa Mon Sep 17 00:00:00 2001 From: Alexandre Emsenhuber Date: Wed, 20 Jun 2012 21:45:11 +0200 Subject: [PATCH] Fix for I5211ec50 (d969a27): more refactoring of the code. No need the reset of ignore_user_abort() since it is not modified anymore; also put global declarations at the beginning of the method. Change-Id: Ie0f06175d9146e20ed10bbe3dddecc5004af554f --- includes/WikiPage.php | 55 +++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 31 deletions(-) diff --git a/includes/WikiPage.php b/includes/WikiPage.php index c203e4fbf4..52e130ec66 100644 --- a/includes/WikiPage.php +++ b/includes/WikiPage.php @@ -1445,7 +1445,7 @@ class WikiPage extends Page { * Compatibility note: this function previously returned a boolean value indicating success/failure */ public function doEdit( $text, $summary, $flags = 0, $baseRevId = false, $user = null ) { - global $wgUser, $wgUseAutomaticEditSummaries; + global $wgUser, $wgUseAutomaticEditSummaries, $wgUseRCPatrol, $wgUseNPPatrol; # Low-level sanity check if ( $this->mTitle->getText() === '' ) { @@ -1540,45 +1540,40 @@ class WikiPage extends Page { $ok = $this->updateRevisionOn( $dbw, $revision, $oldid, $oldIsRedirect ); if ( !$ok ) { - /* Belated edit conflict! Run away!! */ + # Belated edit conflict! Run away!! $status->fatal( 'edit-conflict' ); - $revisionId = 0; $dbw->rollback( __METHOD__ ); - } else { - global $wgUseRCPatrol; - wfRunHooks( 'NewRevisionFromEditComplete', array( $this, $revision, $baseRevId, $user ) ); - # Update recentchanges - if ( !( $flags & EDIT_SUPPRESS_RC ) ) { - # 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, - $revisionId, $patrolled - ); - - # Log auto-patrolled edits - if ( $patrolled ) { - PatrolLog::record( $rc, true, $user ); - } + + wfProfileOut( __METHOD__ ); + return $status; + } + + wfRunHooks( 'NewRevisionFromEditComplete', array( $this, $revision, $baseRevId, $user ) ); + # Update recentchanges + if ( !( $flags & EDIT_SUPPRESS_RC ) ) { + # 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, + $revisionId, $patrolled + ); + + # Log auto-patrolled edits + if ( $patrolled ) { + PatrolLog::record( $rc, true, $user ); } - $user->incEditCount(); - $dbw->commit( __METHOD__ ); } + $user->incEditCount(); + $dbw->commit( __METHOD__ ); } else { // Bug 32948: revision ID must be set to page {{REVISIONID}} and // related variables correctly $revision->setId( $this->getLatest() ); } - // Now that ignore_user_abort is restored, we can respond to fatal errors - if ( !$status->isOK() ) { - wfProfileOut( __METHOD__ ); - return $status; - } - # Update links tables, site stats, etc. $this->doEditUpdates( $revision, $user, array( 'changed' => $changed, 'oldcountable' => $oldcountable ) ); @@ -1627,8 +1622,6 @@ class WikiPage extends Page { # Update recentchanges if ( !( $flags & EDIT_SUPPRESS_RC ) ) { - global $wgUseRCPatrol, $wgUseNPPatrol; - # Mark as patrolled if the user can do so $patrolled = ( $wgUseRCPatrol || $wgUseNPPatrol ) && !count( $this->mTitle->getUserPermissionsErrors( 'autopatrol', $user ) ); -- 2.20.1