From: Aaron Schulz Date: Fri, 25 Sep 2015 06:19:06 +0000 (-0700) Subject: Avoid CAS errors on double post to ApiOptions X-Git-Tag: 1.31.0-rc.0~9700^2 X-Git-Url: http://git.cyclocoop.org/%22%20%20.%20generer_url_ecrire%28%22mots_tous%22%29%20.%20%22?a=commitdiff_plain;h=ece85dd20f7e3a69f56ec9d9af25bcaf6762aed2;p=lhc%2Fweb%2Fwiklou.git Avoid CAS errors on double post to ApiOptions Bug: T95839 Change-Id: I62f8eea31164be1ab0eacf31c494f0b296b367f2 --- diff --git a/includes/User.php b/includes/User.php index d57dfaac15..31d3a99976 100644 --- a/includes/User.php +++ b/includes/User.php @@ -1203,18 +1203,15 @@ class User implements IDBAccessObject { return false; } - $db = ( $flags & self::READ_LATEST ) - ? wfGetDB( DB_MASTER ) - : wfGetDB( DB_SLAVE ); + list( $index, $options ) = DBAccessObjectUtils::getDBOptions( $flags ); + $db = wfGetDB( $index ); $s = $db->selectRow( 'user', self::selectFields(), array( 'user_id' => $this->mId ), __METHOD__, - ( ( $flags & self::READ_LOCKING ) == self::READ_LOCKING ) - ? array( 'LOCK IN SHARE MODE' ) - : array() + $options ); $this->queryFlagsUsed = $flags; diff --git a/includes/api/ApiOptions.php b/includes/api/ApiOptions.php index a62bcb6d56..74ce0539d5 100644 --- a/includes/api/ApiOptions.php +++ b/includes/api/ApiOptions.php @@ -55,7 +55,7 @@ class ApiOptions extends ApiBase { // 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 ) ) { + if ( !$user->loadFromId( User::READ_EXCLUSIVE ) ) { $this->dieUsage( 'Anonymous users cannot change preferences', 'notloggedin' ); } }