From 7995f22de5b8a7f89dd696b6adc342e4b3340bec Mon Sep 17 00:00:00 2001 From: Cristian Scheid Date: Thu, 17 Sep 2026 11:34:39 -0300 Subject: [PATCH] fix(promote-owner): avoid DB errors on postgres databases Signed-off-by: Cristian Scheid --- lib/Db/MemberRequest.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/Db/MemberRequest.php b/lib/Db/MemberRequest.php index c4c66598c..df29cd0db 100644 --- a/lib/Db/MemberRequest.php +++ b/lib/Db/MemberRequest.php @@ -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);