Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions lib/Db/MemberRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,12 +194,16 @@ public function promoteToOwner(Member $member): ?Member {
try {
$this->db->beginTransaction();

$qb = $this->getMemberSelectSql();
$qb = $this->getMemberSelectSql(null, false);
$qb->limitToCircleId($member->getCircleId());
$qb->limitInt('level', Member::LEVEL_OWNER);
// forUpdate locks the owner row until transaction is commited, forcing concurrent

// forUpdate() locks the owner row until transaction is commited, forcing concurrent
// requests to wait and read the updated current owner, preventing multiple owners
$qb->forUpdate();
// Not needed/supported on SQLite, which only allows one writer at a time anyway
if ($this->db->getDatabaseProvider() !== IDBConnection::PLATFORM_SQLITE) {
$qb->forUpdate();
}

try {
$oldOwner = $this->getItemFromRequest($qb);
Expand Down
Loading