From: Aaron Schulz Date: Wed, 26 Aug 2015 00:27:46 +0000 (-0700) Subject: Load User via READ_LATEST in ApiOptions to avoid CAS errors X-Git-Tag: 1.31.0-rc.0~10245^2 X-Git-Url: http://git.cyclocoop.org/%24self?a=commitdiff_plain;h=129586e1d9586f506b6b6ff2b01df1535067c436;p=lhc%2Fweb%2Fwiklou.git Load User via READ_LATEST in ApiOptions to avoid CAS errors Bug: T95839 Change-Id: I3c4cf4347af24f3313e709a996618b755da22dd2 --- diff --git a/includes/api/ApiOptions.php b/includes/api/ApiOptions.php index 436f22aee5..a62bcb6d56 100644 --- a/includes/api/ApiOptions.php +++ b/includes/api/ApiOptions.php @@ -52,6 +52,14 @@ class ApiOptions extends ApiBase { $this->dieUsageMsg( array( 'missingparam', 'optionname' ) ); } + // Load the user from the master to reduce CAS errors on double post (T95839) + if ( wfGetLB()->getServerCount() > 1 ) { + $user = User::newFromId( $user->getId() ); + if ( !$user->loadFromId( User::READ_LATEST ) ) { + $this->dieUsage( 'Anonymous users cannot change preferences', 'notloggedin' ); + } + } + if ( $params['reset'] ) { $user->resetOptions( $params['resetkinds'], $this->getContext() ); $changed = true;