From 28404fad368d2c363b2c76b1dccc5460aa34dfc1 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Thu, 16 Apr 2015 10:54:26 -0700 Subject: [PATCH] Made saveSettings() CAS check handle caught DB exceptions better Change-Id: I8e9e75af437e00a76e4184908c579a6702c9023a --- includes/User.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/includes/User.php b/includes/User.php index 59d5c03cf8..b122a9fd96 100644 --- a/includes/User.php +++ b/includes/User.php @@ -3603,7 +3603,7 @@ class User implements IDBAccessObject { // This will be used for a CAS check as a last-resort safety // check against race conditions and slave lag. $oldTouched = $this->mTouched; - $this->mTouched = $this->newTouchedTimestamp(); + $newTouched = $this->newTouchedTimestamp(); if ( !$wgAuth->allowSetLocalPassword() ) { $this->mPassword = self::getPasswordFactory()->newFromCiphertext( null ); @@ -3619,7 +3619,7 @@ class User implements IDBAccessObject { 'user_real_name' => $this->mRealName, 'user_email' => $this->mEmail, 'user_email_authenticated' => $dbw->timestampOrNull( $this->mEmailAuthenticated ), - 'user_touched' => $dbw->timestamp( $this->mTouched ), + 'user_touched' => $dbw->timestamp( $newTouched ), 'user_token' => strval( $this->mToken ), 'user_email_token' => $this->mEmailToken, 'user_email_token_expires' => $dbw->timestampOrNull( $this->mEmailTokenExpires ), @@ -3631,17 +3631,18 @@ class User implements IDBAccessObject { ); if ( !$dbw->affectedRows() ) { + // Maybe the problem was a missed cache update; clear it to be safe + $this->clearSharedCache(); // User was changed in the meantime or loaded with stale data MWExceptionHandler::logException( new MWException( "CAS update failed on user_touched for user ID '{$this->mId}';" . "the version of the user to be saved is older than the current version." ) ); - // Maybe the problem was a missed cache update; clear it to be safe - $this->clearSharedCache(); return; } + $this->mTouched = $newTouched; $this->saveOptions(); Hooks::run( 'UserSaveSettings', array( $this ) ); -- 2.20.1