summaryrefslogtreecommitdiffstats
path: root/lib/public
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@users.noreply.github.com>2021-04-16 11:12:41 +0200
committerGitHub <noreply@github.com>2021-04-16 11:12:41 +0200
commit403388269a15c11e06c8d8585fefec4e78aa343b (patch)
tree3d8446495b35a00a5e41564178f33d66b5cf7f73 /lib/public
parentec66943efd86e41ffaf2257b2f1d67f3d4f32487 (diff)
parent25d11b5197ee529b6e3b8d1d0d338f3c5db9088c (diff)
downloadnextcloud-server-403388269a15c11e06c8d8585fefec4e78aa343b.tar.gz
nextcloud-server-403388269a15c11e06c8d8585fefec4e78aa343b.zip
Merge pull request #26581 from nextcloud/bugfix/noid/fix-device-login
Fix constraint violation detection in QB Mapper
Diffstat (limited to 'lib/public')
-rw-r--r--lib/public/AppFramework/Db/QBMapper.php9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/public/AppFramework/Db/QBMapper.php b/lib/public/AppFramework/Db/QBMapper.php
index 3fc7942c0dd..ac6520a9d03 100644
--- a/lib/public/AppFramework/Db/QBMapper.php
+++ b/lib/public/AppFramework/Db/QBMapper.php
@@ -30,7 +30,7 @@ declare(strict_types=1);
namespace OCP\AppFramework\Db;
-use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
+use OCP\DB\Exception;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IDBConnection;
@@ -157,8 +157,11 @@ abstract class QBMapper {
public function insertOrUpdate(Entity $entity): Entity {
try {
return $this->insert($entity);
- } catch (UniqueConstraintViolationException $ex) {
- return $this->update($entity);
+ } catch (Exception $ex) {
+ if ($ex->getReason() === Exception::REASON_UNIQUE_CONSTRAINT_VIOLATION) {
+ return $this->update($entity);
+ }
+ throw $ex;
}
}