Skip to content

Commit ab233d5

Browse files
authored
Merge pull request #27729 from nextcloud/revert-26587-backport/26581/stable21
[stable21] Revert "Fix constraint violation detection in QB Mapper"
2 parents 0aed3ec + affe972 commit ab233d5

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

lib/public/AppFramework/Db/QBMapper.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
namespace OCP\AppFramework\Db;
3232

33-
use OCP\DB\Exception;
33+
use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
3434
use OCP\DB\QueryBuilder\IQueryBuilder;
3535
use OCP\IDBConnection;
3636

@@ -162,11 +162,8 @@ public function insert(Entity $entity): Entity {
162162
public function insertOrUpdate(Entity $entity): Entity {
163163
try {
164164
return $this->insert($entity);
165-
} catch (Exception $ex) {
166-
if ($ex->getReason() === Exception::REASON_UNIQUE_CONSTRAINT_VIOLATION) {
167-
return $this->update($entity);
168-
}
169-
throw $ex;
165+
} catch (UniqueConstraintViolationException $ex) {
166+
return $this->update($entity);
170167
}
171168
}
172169

0 commit comments

Comments
 (0)