Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/polls.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Service')
-rw-r--r--lib/Service/LogService.php4
-rw-r--r--lib/Service/OptionService.php6
-rw-r--r--lib/Service/SubscriptionService.php4
3 files changed, 14 insertions, 0 deletions
diff --git a/lib/Service/LogService.php b/lib/Service/LogService.php
index e4bef90a..78ad090a 100644
--- a/lib/Service/LogService.php
+++ b/lib/Service/LogService.php
@@ -23,6 +23,7 @@
namespace OCA\Polls\Service;
+use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
use OCP\DB\Exception;
use OCA\Polls\Db\Log;
use OCA\Polls\Db\LogMapper;
@@ -57,6 +58,9 @@ class LogService {
try {
return $this->logMapper->insert($this->log);
+ } catch (UniqueConstraintViolationException $e) {
+ // deprecated NC22
+ return null;
} catch (Exception $e) {
if ($e->getReason() === Exception::REASON_UNIQUE_CONSTRAINT_VIOLATION) {
return null;
diff --git a/lib/Service/OptionService.php b/lib/Service/OptionService.php
index 195f78da..9db06f2c 100644
--- a/lib/Service/OptionService.php
+++ b/lib/Service/OptionService.php
@@ -163,6 +163,9 @@ class OptionService {
try {
$this->option = $this->optionMapper->insert($this->option);
+ } catch (UniqueConstraintViolationException $e) {
+ // deprecated NC22
+ throw new DuplicateEntryException('This option already exists');
} catch (Exception $e) {
if ($e->getReason() === Exception::REASON_UNIQUE_CONSTRAINT_VIOLATION) {
throw new DuplicateEntryException('This option already exists');
@@ -270,6 +273,9 @@ class OptionService {
try {
$this->optionMapper->insert($clonedOption);
+ } catch (UniqueConstraintViolationException $e) {
+ // deprecated NC22
+ $this->logger->warning('skip adding ' . $baseDate->format('c') . 'for pollId' . $this->option->getPollId() . '. Option already exists.');
} catch (Exception $e) {
if ($e->getReason() === Exception::REASON_UNIQUE_CONSTRAINT_VIOLATION) {
$this->logger->warning('skip adding ' . $baseDate->format('c') . 'for pollId' . $this->option->getPollId() . '. Option already exists.');
diff --git a/lib/Service/SubscriptionService.php b/lib/Service/SubscriptionService.php
index 558be8fe..e8f68442 100644
--- a/lib/Service/SubscriptionService.php
+++ b/lib/Service/SubscriptionService.php
@@ -23,6 +23,7 @@
namespace OCA\Polls\Service;
+use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
use OCP\AppFramework\Db\DoesNotExistException;
use OCP\DB\Exception;
@@ -86,6 +87,9 @@ class SubscriptionService {
} else {
try {
$this->add($this->acl->getPollId(), $this->acl->getUserId());
+ } catch (UniqueConstraintViolationException $e) {
+ // deprecated NC22
+ // catch silently (assume already subscribed)
} catch (Exception $e) {
if ($e->getReason() === Exception::REASON_UNIQUE_CONSTRAINT_VIOLATION) {
// catch silently (assume already subscribed)