diff --git a/UPGRADE-2.16.md b/UPGRADE-2.16.md new file mode 100644 index 000000000..f11dffde8 --- /dev/null +++ b/UPGRADE-2.16.md @@ -0,0 +1,10 @@ +# UPGRADE FROM 2.15 to 2.16 + +## Package `doctrine/cache` + +The package `doctrine/cache` is no longer required. + +If you use `Doctrine\ODM\MongoDB\Configuration::getMetadataCacheImpl()`, +then you need to require `doctrine/cache` explicitly in your `composer.json`; +or use `Doctrine\ODM\MongoDB\Configuration::getMetadataCache()` instead. + diff --git a/composer.json b/composer.json index 159d0c088..fda216e5e 100644 --- a/composer.json +++ b/composer.json @@ -28,7 +28,6 @@ "require": { "php": "^8.1", "ext-mongodb": "^1.21 || ^2.0", - "doctrine/cache": "^1.11 || ^2.0", "doctrine/collections": "^1.5 || ^2.0", "doctrine/event-manager": "^1.0 || ^2.0", "doctrine/instantiator": "^1.1 || ^2", @@ -45,6 +44,7 @@ "require-dev": { "ext-bcmath": "*", "doctrine/annotations": "^1.12 || ^2.0", + "doctrine/cache": "^2.0", "doctrine/coding-standard": "^14.0", "doctrine/orm": "^3.2", "jmikola/geojson": "^1.0", @@ -58,7 +58,9 @@ "symfony/uid": "^5.4 || ^6.0 || ^7.0 || ^8.0" }, "conflict": { - "doctrine/annotations": "<1.12 || >=3.0" + "doctrine/annotations": "<1.12 || >=3.0", + "doctrine/cache": "<1.11", + "doctrine/mongodb-odm-bundle": "<5" }, "suggest": { "doctrine/annotations": "For annotation mapping support", diff --git a/src/Configuration.php b/src/Configuration.php index 8e1faf488..429850cc6 100644 --- a/src/Configuration.php +++ b/src/Configuration.php @@ -276,8 +276,13 @@ public function getMetadataDriverImpl(): ?MappingDriver return $this->attributes['metadataDriverImpl'] ?? null; } + /** @deprecated Since 2.2, use {@see getMetadataCache()} instead. */ public function getMetadataCacheImpl(): ?Cache { + if (! class_exists(DoctrineProvider::class)) { + throw new LogicException('The "doctrine/cache" package is deprecated and no longer required by "doctrine/mongodb-odm". Use "getMetadataCache"'); + } + trigger_deprecation( 'doctrine/mongodb-odm', '2.2', @@ -289,6 +294,7 @@ public function getMetadataCacheImpl(): ?Cache return $this->attributes['metadataCacheImpl'] ?? null; } + /** @deprecated Since 2.2, use {@see setMetadataCache()} instead. */ public function setMetadataCacheImpl(Cache $cacheImpl): void { trigger_deprecation( @@ -310,7 +316,12 @@ public function getMetadataCache(): ?CacheItemPoolInterface public function setMetadataCache(CacheItemPoolInterface $cache): void { - $this->metadataCache = $cache; + $this->metadataCache = $cache; + + if (! class_exists(DoctrineProvider::class)) { + return; + } + $this->attributes['metadataCacheImpl'] = DoctrineProvider::wrap($cache); }