From c4eecf4eb6304ba8405fd1f6afbb3019c85572f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Tamarelle?= Date: Fri, 14 Nov 2025 22:46:48 +0100 Subject: [PATCH 1/5] Stronger deprecation of doctrine/cache --- composer.json | 2 +- src/Configuration.php | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 159d0c088..54a538af4 100644 --- a/composer.json +++ b/composer.json @@ -28,7 +28,7 @@ "require": { "php": "^8.1", "ext-mongodb": "^1.21 || ^2.0", - "doctrine/cache": "^1.11 || ^2.0", + "doctrine/cache": "^2.0", "doctrine/collections": "^1.5 || ^2.0", "doctrine/event-manager": "^1.0 || ^2.0", "doctrine/instantiator": "^1.1 || ^2", diff --git a/src/Configuration.php b/src/Configuration.php index 8e1faf488..5a47fb71b 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 (! interface_exists(Cache::class)) { + throw new LogicException('The "doctrine/cache" package is deprecated and no longer installed with "doctrine/mongodb-odm". Require .'); + } + 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( From 9d417caefcb75bc9fa4c83c4cc12601f93f391e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Tamarelle?= Date: Fri, 14 Nov 2025 23:02:34 +0100 Subject: [PATCH 2/5] Move doctrine/cache to optional dependencies --- composer.json | 5 +++-- src/Configuration.php | 11 ++++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index 54a538af4..3eff1819d 100644 --- a/composer.json +++ b/composer.json @@ -28,7 +28,6 @@ "require": { "php": "^8.1", "ext-mongodb": "^1.21 || ^2.0", - "doctrine/cache": "^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,8 @@ "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" }, "suggest": { "doctrine/annotations": "For annotation mapping support", diff --git a/src/Configuration.php b/src/Configuration.php index 5a47fb71b..429850cc6 100644 --- a/src/Configuration.php +++ b/src/Configuration.php @@ -279,8 +279,8 @@ public function getMetadataDriverImpl(): ?MappingDriver /** @deprecated Since 2.2, use {@see getMetadataCache()} instead. */ public function getMetadataCacheImpl(): ?Cache { - if (! interface_exists(Cache::class)) { - throw new LogicException('The "doctrine/cache" package is deprecated and no longer installed with "doctrine/mongodb-odm". Require .'); + 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( @@ -316,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); } From bc66e60636ed87666005e4f29df41dada2e7156d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Tamarelle?= Date: Fri, 14 Nov 2025 23:15:39 +0100 Subject: [PATCH 3/5] Add conflict with doctrine/mongodb-odm-bundle which uses doctrine/cache directly https://github.com/doctrine/DoctrineMongoDBBundle/blob/48c29009c24ff74c47782c0c9c2736f1f5fd9b0e/DependencyInjection/DoctrineMongoDBExtension.php#L14-L15 --- composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 3eff1819d..fda216e5e 100644 --- a/composer.json +++ b/composer.json @@ -59,7 +59,8 @@ }, "conflict": { "doctrine/annotations": "<1.12 || >=3.0", - "doctrine/cache": "<1.11" + "doctrine/cache": "<1.11", + "doctrine/mongodb-odm-bundle": "<5" }, "suggest": { "doctrine/annotations": "For annotation mapping support", From ff0af5a6784b0cfac0cfe73f1f8271044a5e10a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Tamarelle?= Date: Mon, 17 Nov 2025 21:28:11 +0100 Subject: [PATCH 4/5] Add upgrade instructions --- UPGRADE-2.16.md | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 UPGRADE-2.16.md diff --git a/UPGRADE-2.16.md b/UPGRADE-2.16.md new file mode 100644 index 000000000..28206b9ba --- /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` 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. + From 8f014e05567fed03bdc98d40eef4ab7f23c62b86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Tamarelle?= Date: Tue, 18 Nov 2025 22:00:33 +0100 Subject: [PATCH 5/5] Update UPGRADE-2.16.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Grégoire Paris --- UPGRADE-2.16.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UPGRADE-2.16.md b/UPGRADE-2.16.md index 28206b9ba..f11dffde8 100644 --- a/UPGRADE-2.16.md +++ b/UPGRADE-2.16.md @@ -2,7 +2,7 @@ ## Package `doctrine/cache` -The package `doctrine/cache` no longer required. +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`;