mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/AJAXPoll
synced 2024-11-15 03:04:14 +00:00
Replace DB begin()/commit() with startAtomic()/endAtomic() as needed
Bug: T120791 Change-Id: I6d76b2487ea9e77d0fffc2ab22a6640eb2e639b5
This commit is contained in:
parent
b0b9212aa3
commit
844deed643
|
@ -69,7 +69,7 @@ class AJAXPoll {
|
|||
}
|
||||
|
||||
$dbw = wfGetDB( DB_MASTER );
|
||||
$dbw->begin( __METHOD__ );
|
||||
$dbw->startAtomic( __METHOD__ );
|
||||
|
||||
/**
|
||||
* Register poll in the database
|
||||
|
@ -115,7 +115,7 @@ class AJAXPoll {
|
|||
);
|
||||
}
|
||||
|
||||
$dbw->commit( __METHOD__ );
|
||||
$dbw->endAtomic( __METHOD__ );
|
||||
|
||||
switch ( $lines[0] ) {
|
||||
case 'STATS':
|
||||
|
@ -190,9 +190,6 @@ During the last 48 hours, $tab2[0] votes have been given.";
|
|||
public static function submitVote( $id, $answer, $token ) {
|
||||
global $wgUser, $wgRequest;
|
||||
|
||||
$dbw = wfGetDB( DB_MASTER );
|
||||
$dbw->begin( __METHOD__ );
|
||||
|
||||
if ( $wgUser->getName() == '' ) {
|
||||
$userName = $wgRequest->getIP();
|
||||
} else {
|
||||
|
@ -209,6 +206,9 @@ During the last 48 hours, $tab2[0] votes have been given.";
|
|||
return self::buildHTML( $id, $userName );
|
||||
}
|
||||
|
||||
$dbw = wfGetDB( DB_MASTER );
|
||||
$dbw->startAtomic( __METHOD__ );
|
||||
|
||||
if ( $answer != 0 ) {
|
||||
|
||||
$answer = ++$answer;
|
||||
|
@ -238,7 +238,6 @@ During the last 48 hours, $tab2[0] votes have been given.";
|
|||
),
|
||||
__METHOD__
|
||||
);
|
||||
$dbw->commit( __METHOD__ );
|
||||
$pollContainerText = ( $updateQuery ) ? 'ajaxpoll-vote-update' : 'ajaxpoll-vote-error';
|
||||
} else {
|
||||
|
||||
|
@ -253,7 +252,6 @@ During the last 48 hours, $tab2[0] votes have been given.";
|
|||
),
|
||||
__METHOD__
|
||||
);
|
||||
$dbw->commit( __METHOD__ );
|
||||
$pollContainerText = ( $insertQuery ) ? 'ajaxpoll-vote-add' : 'ajaxpoll-vote-error';
|
||||
}
|
||||
} else { // revoking a vote
|
||||
|
@ -266,10 +264,11 @@ During the last 48 hours, $tab2[0] votes have been given.";
|
|||
),
|
||||
__METHOD__
|
||||
);
|
||||
$dbw->commit( __METHOD__ );
|
||||
$pollContainerText = ( $deleteQuery ) ? 'ajaxpoll-vote-revoked' : 'ajaxpoll-vote-error';
|
||||
}
|
||||
|
||||
$dbw->endAtomic( __METHOD__ );
|
||||
|
||||
return self::buildHTML( $id, $userName, '', $pollContainerText );
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue