diff options
author | René Gieling <github@dartcafe.de> | 2021-07-08 09:32:32 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-08 09:32:32 +0300 |
commit | 9ea4320b1ac821fea6a68ac524f4a3884da9ba5b (patch) | |
tree | 5ad103ef1d036f71a33ec13ef670c463f359495e | |
parent | 94f67618fd3631fd69905b27f5a0207a40a63ad8 (diff) | |
parent | f78c40e6041973dca844a2c094bdb3a96c2d2295 (diff) |
Merge pull request #1823 from nextcloud/fix/DBAL-exceptions
NC21 compatibility - keep DBAL Exceptions
-rw-r--r-- | composer.json | 3 | ||||
-rw-r--r-- | composer.lock | 495 | ||||
-rw-r--r-- | lib/Db/LogMapper.php | 4 | ||||
-rw-r--r-- | lib/Db/OptionMapper.php | 4 | ||||
-rw-r--r-- | lib/Db/PreferencesMapper.php | 4 | ||||
-rw-r--r-- | lib/Db/ShareMapper.php | 4 | ||||
-rw-r--r-- | lib/Db/SubscriptionMapper.php | 4 | ||||
-rw-r--r-- | lib/Db/VoteMapper.php | 4 | ||||
-rw-r--r-- | lib/Service/LogService.php | 4 | ||||
-rw-r--r-- | lib/Service/OptionService.php | 6 | ||||
-rw-r--r-- | lib/Service/SubscriptionService.php | 4 |
11 files changed, 460 insertions, 76 deletions
diff --git a/composer.json b/composer.json index b23524c9..fb81be6f 100644 --- a/composer.json +++ b/composer.json @@ -40,6 +40,7 @@ "psalm:info": "php vendor/vimeo/psalm/psalm --show-info=true" }, "require": { - "league/commonmark": "^1.6" + "league/commonmark": "^1.6", + "doctrine/dbal": "^3.1" } } diff --git a/composer.lock b/composer.lock index d818fea2..ca2e869f 100644 --- a/composer.lock +++ b/composer.lock @@ -4,9 +4,427 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "cea8741587b93250f2342f8d3b650406", + "content-hash": "eab175e089d9d04ef95e327dfe9271a9", "packages": [ { + "name": "composer/package-versions-deprecated", + "version": "1.11.99.2", + "source": { + "type": "git", + "url": "https://github.com/composer/package-versions-deprecated.git", + "reference": "c6522afe5540d5fc46675043d3ed5a45a740b27c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/package-versions-deprecated/zipball/c6522afe5540d5fc46675043d3ed5a45a740b27c", + "reference": "c6522afe5540d5fc46675043d3ed5a45a740b27c", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^1.1.0 || ^2.0", + "php": "^7 || ^8" + }, + "replace": { + "ocramius/package-versions": "1.11.99" + }, + "require-dev": { + "composer/composer": "^1.9.3 || ^2.0@dev", + "ext-zip": "^1.13", + "phpunit/phpunit": "^6.5 || ^7" + }, + "type": "composer-plugin", + "extra": { + "class": "PackageVersions\\Installer", + "branch-alias": { + "dev-master": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "PackageVersions\\": "src/PackageVersions" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Marco Pivetta", + "email": "ocramius@gmail.com" + }, + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be" + } + ], + "description": "Composer plugin that provides efficient querying for installed package versions (no runtime IO)", + "support": { + "issues": "https://github.com/composer/package-versions-deprecated/issues", + "source": "https://github.com/composer/package-versions-deprecated/tree/1.11.99.2" + }, + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], + "time": "2021-05-24T07:46:03+00:00" + }, + { + "name": "doctrine/cache", + "version": "2.0.3", + "source": { + "type": "git", + "url": "https://github.com/doctrine/cache.git", + "reference": "c9622c6820d3ede1e2315a6a377ea1076e421d88" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/cache/zipball/c9622c6820d3ede1e2315a6a377ea1076e421d88", + "reference": "c9622c6820d3ede1e2315a6a377ea1076e421d88", + "shasum": "" + }, + "require": { + "php": "~7.1 || ^8.0" + }, + "conflict": { + "doctrine/common": ">2.2,<2.4", + "psr/cache": ">=3" + }, + "require-dev": { + "alcaeus/mongo-php-adapter": "^1.1", + "cache/integration-tests": "dev-master", + "doctrine/coding-standard": "^8.0", + "mongodb/mongodb": "^1.1", + "phpunit/phpunit": "^7.0 || ^8.0 || ^9.0", + "predis/predis": "~1.0", + "psr/cache": "^1.0 || ^2.0", + "symfony/cache": "^4.4 || ^5.2" + }, + "suggest": { + "alcaeus/mongo-php-adapter": "Required to use legacy MongoDB driver" + }, + "type": "library", + "autoload": { + "psr-4": { + "Doctrine\\Common\\Cache\\": "lib/Doctrine/Common/Cache" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "PHP Doctrine Cache library is a popular cache implementation that supports many different drivers such as redis, memcache, apc, mongodb and others.", + "homepage": "https://www.doctrine-project.org/projects/cache.html", + "keywords": [ + "abstraction", + "apcu", + "cache", + "caching", + "couchdb", + "memcached", + "php", + "redis", + "xcache" + ], + "support": { + "issues": "https://github.com/doctrine/cache/issues", + "source": "https://github.com/doctrine/cache/tree/2.0.3" + }, + "funding": [ + { + "url": "https://www.doctrine-project.org/sponsorship.html", + "type": "custom" + }, + { + "url": "https://www.patreon.com/phpdoctrine", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/doctrine%2Fcache", + "type": "tidelift" + } + ], + "time": "2021-05-25T09:43:04+00:00" + }, + { + "name": "doctrine/dbal", + "version": "3.1.1", + "source": { + "type": "git", + "url": "https://github.com/doctrine/dbal.git", + "reference": "8e0fde2b90e3f61361013d1e928621beeea07bc0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/dbal/zipball/8e0fde2b90e3f61361013d1e928621beeea07bc0", + "reference": "8e0fde2b90e3f61361013d1e928621beeea07bc0", + "shasum": "" + }, + "require": { + "composer/package-versions-deprecated": "^1.11.99", + "doctrine/cache": "^1.0|^2.0", + "doctrine/deprecations": "^0.5.3", + "doctrine/event-manager": "^1.0", + "php": "^7.3 || ^8.0" + }, + "require-dev": { + "doctrine/coding-standard": "9.0.0", + "jetbrains/phpstorm-stubs": "2020.2", + "phpstan/phpstan": "0.12.81", + "phpstan/phpstan-strict-rules": "^0.12.2", + "phpunit/phpunit": "9.5.5", + "psalm/plugin-phpunit": "0.13.0", + "squizlabs/php_codesniffer": "3.6.0", + "symfony/cache": "^5.2|^6.0", + "symfony/console": "^2.0.5|^3.0|^4.0|^5.0|^6.0", + "vimeo/psalm": "4.6.4" + }, + "suggest": { + "symfony/console": "For helpful console commands such as SQL execution and import of files." + }, + "bin": [ + "bin/doctrine-dbal" + ], + "type": "library", + "autoload": { + "psr-4": { + "Doctrine\\DBAL\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + } + ], + "description": "Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management.", + "homepage": "https://www.doctrine-project.org/projects/dbal.html", + "keywords": [ + "abstraction", + "database", + "db2", + "dbal", + "mariadb", + "mssql", + "mysql", + "oci8", + "oracle", + "pdo", + "pgsql", + "postgresql", + "queryobject", + "sasql", + "sql", + "sqlite", + "sqlserver", + "sqlsrv" + ], + "support": { + "issues": "https://github.com/doctrine/dbal/issues", + "source": "https://github.com/doctrine/dbal/tree/3.1.1" + }, + "funding": [ + { + "url": "https://www.doctrine-project.org/sponsorship.html", + "type": "custom" + }, + { + "url": "https://www.patreon.com/phpdoctrine", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/doctrine%2Fdbal", + "type": "tidelift" + } + ], + "time": "2021-06-19T17:59:55+00:00" + }, + { + "name": "doctrine/deprecations", + "version": "v0.5.3", + "source": { + "type": "git", + "url": "https://github.com/doctrine/deprecations.git", + "reference": "9504165960a1f83cc1480e2be1dd0a0478561314" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/deprecations/zipball/9504165960a1f83cc1480e2be1dd0a0478561314", + "reference": "9504165960a1f83cc1480e2be1dd0a0478561314", + "shasum": "" + }, + "require": { + "php": "^7.1|^8.0" + }, + "require-dev": { + "doctrine/coding-standard": "^6.0|^7.0|^8.0", + "phpunit/phpunit": "^7.0|^8.0|^9.0", + "psr/log": "^1.0" + }, + "suggest": { + "psr/log": "Allows logging deprecations via PSR-3 logger implementation" + }, + "type": "library", + "autoload": { + "psr-4": { + "Doctrine\\Deprecations\\": "lib/Doctrine/Deprecations" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "A small layer on top of trigger_error(E_USER_DEPRECATED) or PSR-3 logging with options to disable all deprecations or selectively for packages.", + "homepage": "https://www.doctrine-project.org/", + "support": { + "issues": "https://github.com/doctrine/deprecations/issues", + "source": "https://github.com/doctrine/deprecations/tree/v0.5.3" + }, + "time": "2021-03-21T12:59:47+00:00" + }, + { + "name": "doctrine/event-manager", + "version": "1.1.1", + "source": { + "type": "git", + "url": "https://github.com/doctrine/event-manager.git", + "reference": "41370af6a30faa9dc0368c4a6814d596e81aba7f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/event-manager/zipball/41370af6a30faa9dc0368c4a6814d596e81aba7f", + "reference": "41370af6a30faa9dc0368c4a6814d596e81aba7f", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0" + }, + "conflict": { + "doctrine/common": "<2.9@dev" + }, + "require-dev": { + "doctrine/coding-standard": "^6.0", + "phpunit/phpunit": "^7.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Doctrine\\Common\\": "lib/Doctrine/Common" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + }, + { + "name": "Marco Pivetta", + "email": "ocramius@gmail.com" + } + ], + "description": "The Doctrine Event Manager is a simple PHP event system that was built to be used with the various Doctrine projects.", + "homepage": "https://www.doctrine-project.org/projects/event-manager.html", + "keywords": [ + "event", + "event dispatcher", + "event manager", + "event system", + "events" + ], + "support": { + "issues": "https://github.com/doctrine/event-manager/issues", + "source": "https://github.com/doctrine/event-manager/tree/1.1.x" + }, + "funding": [ + { + "url": "https://www.doctrine-project.org/sponsorship.html", + "type": "custom" + }, + { + "url": "https://www.patreon.com/phpdoctrine", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/doctrine%2Fevent-manager", + "type": "tidelift" + } + ], + "time": "2020-05-29T18:28:51+00:00" + }, + { "name": "league/commonmark", "version": "1.6.5", "source": { @@ -316,79 +734,6 @@ "time": "2021-03-01T08:42:25+00:00" }, { - "name": "composer/package-versions-deprecated", - "version": "1.11.99.2", - "source": { - "type": "git", - "url": "https://github.com/composer/package-versions-deprecated.git", - "reference": "c6522afe5540d5fc46675043d3ed5a45a740b27c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/composer/package-versions-deprecated/zipball/c6522afe5540d5fc46675043d3ed5a45a740b27c", - "reference": "c6522afe5540d5fc46675043d3ed5a45a740b27c", - "shasum": "" - }, - "require": { - "composer-plugin-api": "^1.1.0 || ^2.0", - "php": "^7 || ^8" - }, - "replace": { - "ocramius/package-versions": "1.11.99" - }, - "require-dev": { - "composer/composer": "^1.9.3 || ^2.0@dev", - "ext-zip": "^1.13", - "phpunit/phpunit": "^6.5 || ^7" - }, - "type": "composer-plugin", - "extra": { - "class": "PackageVersions\\Installer", - "branch-alias": { - "dev-master": "1.x-dev" - } - }, - "autoload": { - "psr-4": { - "PackageVersions\\": "src/PackageVersions" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Marco Pivetta", - "email": "ocramius@gmail.com" - }, - { - "name": "Jordi Boggiano", - "email": "j.boggiano@seld.be" - } - ], - "description": "Composer plugin that provides efficient querying for installed package versions (no runtime IO)", - "support": { - "issues": "https://github.com/composer/package-versions-deprecated/issues", - "source": "https://github.com/composer/package-versions-deprecated/tree/1.11.99.2" - }, - "funding": [ - { - "url": "https://packagist.com", - "type": "custom" - }, - { - "url": "https://github.com/composer", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/composer/composer", - "type": "tidelift" - } - ], - "time": "2021-05-24T07:46:03+00:00" - }, - { "name": "composer/semver", "version": "3.2.5", "source": { @@ -5152,5 +5497,5 @@ "platform-overrides": { "php": "7.4.0" }, - "plugin-api-version": "2.1.0" + "plugin-api-version": "2.0.0" } diff --git a/lib/Db/LogMapper.php b/lib/Db/LogMapper.php index 6649010a..12bf007f 100644 --- a/lib/Db/LogMapper.php +++ b/lib/Db/LogMapper.php @@ -24,6 +24,7 @@ namespace OCA\Polls\Db; +use Doctrine\DBAL\Exception\DatabaseObjectNotFoundException; use OCP\AppFramework\Db\QBMapper; use OCP\DB\Exception; use OCP\DB\QueryBuilder\IQueryBuilder; @@ -137,6 +138,9 @@ class LogMapper extends QBMapper { $entries2Keep[] = $currentRecord; } } + } catch (DatabaseObjectNotFoundException $e) { + // deprecated NC22 + // ignore silently } catch (Exception $e) { if ($e->getReason() === Exception::REASON_DATABASE_OBJECT_NOT_FOUND) { // ignore silently diff --git a/lib/Db/OptionMapper.php b/lib/Db/OptionMapper.php index f740701c..f8ece5c2 100644 --- a/lib/Db/OptionMapper.php +++ b/lib/Db/OptionMapper.php @@ -24,6 +24,7 @@ namespace OCA\Polls\Db; +use Doctrine\DBAL\Exception\DatabaseObjectNotFoundException; use OCP\AppFramework\Db\QBMapper; use OCP\DB\Exception; use OCP\DB\QueryBuilder\IQueryBuilder; @@ -141,6 +142,9 @@ class OptionMapper extends QBMapper { $entries2Keep[] = $currentRecord; } } + } catch (DatabaseObjectNotFoundException $e) { + // deprecated NC22 + // ignore silently } catch (Exception $e) { if ($e->getReason() === Exception::REASON_DATABASE_OBJECT_NOT_FOUND) { // ignore silently diff --git a/lib/Db/PreferencesMapper.php b/lib/Db/PreferencesMapper.php index e6444fed..76461488 100644 --- a/lib/Db/PreferencesMapper.php +++ b/lib/Db/PreferencesMapper.php @@ -24,6 +24,7 @@ namespace OCA\Polls\Db; +use Doctrine\DBAL\Exception\DatabaseObjectNotFoundException; use OCP\AppFramework\Db\QBMapper; use OCP\DB\Exception; use OCP\DB\QueryBuilder\IQueryBuilder; @@ -85,6 +86,9 @@ class PreferencesMapper extends QBMapper { $userskeep[] = $row['user_id']; } } + } catch (DatabaseObjectNotFoundException $e) { + // deprecated NC22 + // ignore silently } catch (Exception $e) { if ($e->getReason() === Exception::REASON_DATABASE_OBJECT_NOT_FOUND) { // ignore silently diff --git a/lib/Db/ShareMapper.php b/lib/Db/ShareMapper.php index 1f8c3018..2e2a0b2f 100644 --- a/lib/Db/ShareMapper.php +++ b/lib/Db/ShareMapper.php @@ -24,6 +24,7 @@ namespace OCA\Polls\Db; +use Doctrine\DBAL\Exception\DatabaseObjectNotFoundException; use OCP\AppFramework\Db\QBMapper; use OCP\DB\Exception; use OCP\DB\QueryBuilder\IQueryBuilder; @@ -187,6 +188,9 @@ class ShareMapper extends QBMapper { $entries2Keep[] = $currentRecord; } } + } catch (DatabaseObjectNotFoundException $e) { + // deprecated NC22 + // ignore silently } catch (Exception $e) { if ($e->getReason() === Exception::REASON_DATABASE_OBJECT_NOT_FOUND) { // ignore silently diff --git a/lib/Db/SubscriptionMapper.php b/lib/Db/SubscriptionMapper.php index f0cc0372..8ba3432d 100644 --- a/lib/Db/SubscriptionMapper.php +++ b/lib/Db/SubscriptionMapper.php @@ -24,6 +24,7 @@ namespace OCA\Polls\Db; +use Doctrine\DBAL\Exception\DatabaseObjectNotFoundException; use OCP\AppFramework\Db\QBMapper; use OCP\DB\Exception; use OCP\DB\QueryBuilder\IQueryBuilder; @@ -132,6 +133,9 @@ class SubscriptionMapper extends QBMapper { $entries2Keep[] = $currentRecord; } } + } catch (DatabaseObjectNotFoundException $e) { + // deprecated NC22 + // ignore silently } catch (Exception $e) { if ($e->getReason() === Exception::REASON_DATABASE_OBJECT_NOT_FOUND) { // ignore silently diff --git a/lib/Db/VoteMapper.php b/lib/Db/VoteMapper.php index cc7ec717..c2b9c2e8 100644 --- a/lib/Db/VoteMapper.php +++ b/lib/Db/VoteMapper.php @@ -24,6 +24,7 @@ namespace OCA\Polls\Db; +use Doctrine\DBAL\Exception\DatabaseObjectNotFoundException; use OCP\AppFramework\Db\QBMapper; use OCP\DB\Exception; use OCP\DB\QueryBuilder\IQueryBuilder; @@ -193,6 +194,9 @@ class VoteMapper extends QBMapper { $entries2Keep[] = $currentRecord; } } + } catch (DatabaseObjectNotFoundException $e) { + // deprecated NC22 + // ignore silently } catch (Exception $e) { if ($e->getReason() === Exception::REASON_DATABASE_OBJECT_NOT_FOUND) { // ignore silently 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) |