diff --git a/UPGRADE-2.16.md b/UPGRADE-2.16.md index 66ff97d75..f0c3d2708 100644 --- a/UPGRADE-2.16.md +++ b/UPGRADE-2.16.md @@ -1,5 +1,11 @@ # UPGRADE FROM 2.15 to 2.16 +## Package `doctrine/cache` no longer required + +If you use `Doctrine\ODM\MongoDB\Configuration::getMetadataCacheImpl()`, +then you need to require `doctrine/cache` explicitly in `composer.json`; +or use `Doctrine\ODM\MongoDB\Configuration::getMetadataCache()` instead. + ## Lazy Proxy Directory Using proxy classes with PHP 8.4+ is deprecated, only native lazy objects will diff --git a/composer.json b/composer.json index a5cdbf916..aa8041c46 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 6a3e8724c..4fd53486d 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" instead.'); + } + 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); }