From 0a9046946ed7ff874a5f64fd96a97c5c3dc00d8e Mon Sep 17 00:00:00 2001 From: Thomas Rieschl Date: Tue, 12 Sep 2023 21:08:41 +0200 Subject: [PATCH 1/3] Avoid using deprecated methods MongoDB ODM 2.2 deprecated `Doctrine\ODM\MongoDB\Configuration::getMetadataCacheImpl()` and `Doctrine\ODM\MongoDB\Configuration::setMetadataCacheImpl()` in favor of Configuration::getMetadataCache and `Configuration::setMetadataCache()`, respectively which use a PSR-6 compliant cache instead of doctrine/cache. I refrained from allowing to pass a PSR-6 `CacheItemPoolInterface` directly for now, because it's currently unlikely that a cache pulled from `doctrine.cache.[name]` service key will return a PSR-6 cache. Such a change would probably also require changes in doctrine-module and doctrine-orm-module. If you want me to implement that forward compatibility layer right away it's also ok for me. Signed-off-by: Thomas Rieschl --- composer.json | 1 + src/Service/ConfigurationFactory.php | 4 +++- tests/Doctrine/ConfigurationFactoryTest.php | 3 ++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 49c62a8..412ada1 100644 --- a/composer.json +++ b/composer.json @@ -47,6 +47,7 @@ "require": { "php": "~8.0.0 || ~8.1.0 || ~8.2.0", "ext-mongodb": "*", + "doctrine/cache": "^1.11 || ^2.0", "doctrine/doctrine-laminas-hydrator": "^3.3.0", "doctrine/doctrine-module": "^6.0.4", "doctrine/event-manager": "^1.2.0 || ^2.0.0", diff --git a/src/Service/ConfigurationFactory.php b/src/Service/ConfigurationFactory.php index fbf941c..861ccd7 100644 --- a/src/Service/ConfigurationFactory.php +++ b/src/Service/ConfigurationFactory.php @@ -4,6 +4,7 @@ namespace DoctrineMongoODMModule\Service; +use Doctrine\Common\Cache\Psr6\CacheAdapter; use Doctrine\ODM\MongoDB\Configuration; use Doctrine\ODM\MongoDB\Types\Type; use DoctrineMongoODMModule\Options; @@ -68,7 +69,8 @@ public function __invoke(ContainerInterface $container, $requestedName, array|nu } // caching - $config->setMetadataCacheImpl($container->get($configurationOptions->getMetadataCache())); + $cache = $container->get($configurationOptions->getMetadataCache()); + $config->setMetadataCache(CacheAdapter::wrap($cache)); // Register filters foreach ($configurationOptions->getFilters() as $alias => $class) { diff --git a/tests/Doctrine/ConfigurationFactoryTest.php b/tests/Doctrine/ConfigurationFactoryTest.php index 3842df9..92eb731 100644 --- a/tests/Doctrine/ConfigurationFactoryTest.php +++ b/tests/Doctrine/ConfigurationFactoryTest.php @@ -5,6 +5,7 @@ namespace DoctrineMongoODMModuleTest\Doctrine; use Doctrine\Common\Cache\Cache; +use Doctrine\Common\Cache\Psr6\CacheAdapter; use Doctrine\ODM\MongoDB\APM\CommandLoggerInterface; use Doctrine\ODM\MongoDB\Configuration as Config; use Doctrine\ODM\MongoDB\PersistentCollection\PersistentCollectionFactory; @@ -99,7 +100,7 @@ public function testCreation(): void $this->assertInstanceOf(Config::class, $config); - $this->assertSame($metadataCache, $config->getMetadataCacheImpl()); + $this->assertEquals(CacheAdapter::wrap($metadataCache), $config->getMetadataCache()); $this->assertSame($mappingDriver, $config->getMetadataDriverImpl()); $this->assertSame(Config::AUTOGENERATE_EVAL, $config->getAutoGenerateProxyClasses()); From aeadd0eec2867afba822b54a227ec3de2d32e7a7 Mon Sep 17 00:00:00 2001 From: Thomas Rieschl Date: Tue, 10 Oct 2023 14:12:25 +0200 Subject: [PATCH 2/3] adapt for changes in laminas-stdlib 3.18.0 Signed-off-by: Thomas Rieschl --- src/Options/Configuration.php | 2 ++ src/Options/Connection.php | 2 ++ src/Options/DocumentManager.php | 2 ++ src/Options/MongoLoggerCollector.php | 2 ++ 4 files changed, 8 insertions(+) diff --git a/src/Options/Configuration.php b/src/Options/Configuration.php index 0c00230..1740a23 100644 --- a/src/Options/Configuration.php +++ b/src/Options/Configuration.php @@ -12,6 +12,8 @@ /** * Configuration options for doctrine mongo + * + * @extends AbstractOptions|null> */ final class Configuration extends AbstractOptions { diff --git a/src/Options/Connection.php b/src/Options/Connection.php index 1cb7929..bcfd581 100644 --- a/src/Options/Connection.php +++ b/src/Options/Connection.php @@ -8,6 +8,8 @@ /** * Connection options for doctrine mongo + * + * @extends AbstractOptions */ final class Connection extends AbstractOptions { diff --git a/src/Options/DocumentManager.php b/src/Options/DocumentManager.php index c8d227c..966407a 100644 --- a/src/Options/DocumentManager.php +++ b/src/Options/DocumentManager.php @@ -8,6 +8,8 @@ /** * Document manager options for doctrine mongo + * + * @extends AbstractOptions */ final class DocumentManager extends AbstractOptions { diff --git a/src/Options/MongoLoggerCollector.php b/src/Options/MongoLoggerCollector.php index a334c72..5d624dc 100644 --- a/src/Options/MongoLoggerCollector.php +++ b/src/Options/MongoLoggerCollector.php @@ -8,6 +8,8 @@ /** * Configuration options for a collector + * + * @extends AbstractOptions */ final class MongoLoggerCollector extends AbstractOptions { From 334ee7f730f49ed708162444e34f0b0f60d51c09 Mon Sep 17 00:00:00 2001 From: Dennis Riehle Date: Sun, 15 Oct 2023 12:31:18 +0800 Subject: [PATCH 3/3] normalized composer.json --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 412ada1..1eb6e6b 100644 --- a/composer.json +++ b/composer.json @@ -88,8 +88,8 @@ }, "config": { "allow-plugins": { - "dealerdirect/phpcodesniffer-composer-installer": true, - "composer/package-versions-deprecated": true + "composer/package-versions-deprecated": true, + "dealerdirect/phpcodesniffer-composer-installer": true }, "platform": { "ext-mongodb": "1.11.0"