From 5c78adb20dc7d9b1db3cf07e3dc42d982afb0ce3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?C=C3=B4me=20Chilliet?= Date: Mon, 4 Sep 2023 17:52:38 +0200 Subject: [PATCH] Fix Exception catching in OC\DB\Adapter MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- lib/private/DB/Adapter.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/private/DB/Adapter.php b/lib/private/DB/Adapter.php index ec0db318845..ad232aaabd1 100644 --- a/lib/private/DB/Adapter.php +++ b/lib/private/DB/Adapter.php @@ -30,6 +30,7 @@ namespace OC\DB; use Doctrine\DBAL\Exception; use Doctrine\DBAL\Exception\UniqueConstraintViolationException; +use OC\DB\Exceptions\DbalException; /** * This handles the way we use to write queries, into something that can be @@ -143,8 +144,11 @@ class Adapter { $builder->setValue($key, $builder->createNamedParameter($value)); } return $builder->executeStatement(); - } catch (UniqueConstraintViolationException $e) { - return 0; + } catch (DbalException $e) { + if ($e->getReason() === \OCP\DB\Exception::REASON_UNIQUE_CONSTRAINT_VIOLATION) { + return 0; + } + throw $e; } } } -- 2.39.5