Aaron Schulz has uploaded a new change for review.
https://gerrit.wikimedia.org/r/263851
Change subject: Convert code to using startAtomic()/endAtomic()
......................................................................
Convert code to using startAtomic()/endAtomic()
Bug: T120791
Change-Id: Id62d2406d1008f19e3bf3508d0f6727ebaa2a296
---
M includes/user/Auth.php
1 file changed, 7 insertions(+), 6 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/SecurePoll
refs/changes/51/263851/1
diff --git a/includes/user/Auth.php b/includes/user/Auth.php
index 1bc177d..d68b8fc 100644
--- a/includes/user/Auth.php
+++ b/includes/user/Auth.php
@@ -4,6 +4,7 @@
* Class for handling guest logins and sessions. Creates SecurePoll_Voter
objects.
*/
class SecurePoll_Auth {
+ /** @var SecurePoll_Context */
public $context;
/**
@@ -16,7 +17,9 @@
/**
* Create an auth object of the given type
- * @param $type string
+ * @param SecurePoll_Context $context
+ * @param string $type
+ * @throws MWException
*/
static function factory( $context, $type ) {
if ( !isset( self::$authTypes[$type] ) ) {
@@ -111,7 +114,7 @@
# This needs to be protected by FOR UPDATE
# Otherwise a race condition could lead to duplicate users for
a single remote user,
# and thus to duplicate votes.
- $dbw->begin( __METHOD__ );
+ $dbw->startAtomic( __METHOD__ );
$row = $dbw->selectRow(
'securepoll_voters', '*',
array(
@@ -124,14 +127,12 @@
array( 'FOR UPDATE' )
);
if ( $row ) {
- # No need to hold the lock longer
- $dbw->commit( __METHOD__ );
$user = $this->context->newVoterFromRow( $row );
} else {
- # Lock needs to be held until the row is inserted
$user = $this->context->createVoter( $params );
- $dbw->commit( __METHOD__ );
}
+ $dbw->endAtomic( __METHOD__ );
+
return $user;
}
--
To view, visit https://gerrit.wikimedia.org/r/263851
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Id62d2406d1008f19e3bf3508d0f6727ebaa2a296
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/SecurePoll
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits