Skip to content

Commit 04cea4f

Browse files
committed
Stronger deprecation of doctrine/cache
Move doctrine/cache to optional dependencies Add conflict with doctrine/mongodb-odm-bundle which uses doctrine/cache directly https://github.com/doctrine/DoctrineMongoDBBundle/blob/48c29009c24ff74c47782c0c9c2736f1f5fd9b0e/DependencyInjection/DoctrineMongoDBExtension.php#L14-L15 Add upgrade instructions Update UPGRADE-2.16.md Co-authored-by: Grégoire Paris <postmaster@greg0ire.fr> Update UPGRADE-2.16.md Co-authored-by: Jeremy Mikola <jmikola@gmail.com> Update UPGRADE-2.16.md Co-authored-by: Jeremy Mikola <jmikola@gmail.com> Deprecate `Configuration::getProxyDir` and `setProxyDir` (doctrine#2911)
1 parent 5dc850a commit 04cea4f

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

UPGRADE-2.16.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# UPGRADE FROM 2.15 to 2.16
22

3+
## Package `doctrine/cache` no longer required
4+
5+
If you use `Doctrine\ODM\MongoDB\Configuration::getMetadataCacheImpl()`,
6+
then you need to require `doctrine/cache` explicitly in `composer.json`;
7+
or use `Doctrine\ODM\MongoDB\Configuration::getMetadataCache()` instead.
8+
39
## Lazy Proxy Directory
410

511
Using proxy classes with PHP 8.4+ is deprecated, only native lazy objects will

composer.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
"require": {
2929
"php": "^8.1",
3030
"ext-mongodb": "^1.21 || ^2.0",
31-
"doctrine/cache": "^1.11 || ^2.0",
3231
"doctrine/collections": "^1.5 || ^2.0",
3332
"doctrine/event-manager": "^1.0 || ^2.0",
3433
"doctrine/instantiator": "^1.1 || ^2",
@@ -45,6 +44,7 @@
4544
"require-dev": {
4645
"ext-bcmath": "*",
4746
"doctrine/annotations": "^1.12 || ^2.0",
47+
"doctrine/cache": "^2.0",
4848
"doctrine/coding-standard": "^14.0",
4949
"doctrine/orm": "^3.2",
5050
"jmikola/geojson": "^1.0",
@@ -58,7 +58,9 @@
5858
"symfony/uid": "^5.4 || ^6.0 || ^7.0 || ^8.0"
5959
},
6060
"conflict": {
61-
"doctrine/annotations": "<1.12 || >=3.0"
61+
"doctrine/annotations": "<1.12 || >=3.0",
62+
"doctrine/cache": "<1.11",
63+
"doctrine/mongodb-odm-bundle": "<5"
6264
},
6365
"suggest": {
6466
"doctrine/annotations": "For annotation mapping support",

src/Configuration.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,13 @@ public function getMetadataDriverImpl(): ?MappingDriver
276276
return $this->attributes['metadataDriverImpl'] ?? null;
277277
}
278278

279+
/** @deprecated Since 2.2, use {@see getMetadataCache()} instead. */
279280
public function getMetadataCacheImpl(): ?Cache
280281
{
282+
if (! class_exists(DoctrineProvider::class)) {
283+
throw new LogicException('The "doctrine/cache" package is deprecated and no longer required by "doctrine/mongodb-odm". Use "getMetadataCache" instead.');
284+
}
285+
281286
trigger_deprecation(
282287
'doctrine/mongodb-odm',
283288
'2.2',
@@ -289,6 +294,7 @@ public function getMetadataCacheImpl(): ?Cache
289294
return $this->attributes['metadataCacheImpl'] ?? null;
290295
}
291296

297+
/** @deprecated Since 2.2, use {@see setMetadataCache()} instead. */
292298
public function setMetadataCacheImpl(Cache $cacheImpl): void
293299
{
294300
trigger_deprecation(
@@ -310,7 +316,12 @@ public function getMetadataCache(): ?CacheItemPoolInterface
310316

311317
public function setMetadataCache(CacheItemPoolInterface $cache): void
312318
{
313-
$this->metadataCache = $cache;
319+
$this->metadataCache = $cache;
320+
321+
if (! class_exists(DoctrineProvider::class)) {
322+
return;
323+
}
324+
314325
$this->attributes['metadataCacheImpl'] = DoctrineProvider::wrap($cache);
315326
}
316327

0 commit comments

Comments
 (0)