Skip to content

Commit 7abd106

Browse files
committed
Merge branch '2.9.x' into merge/2.9.x
* 2.9.x: Restore functional cache tests (doctrine#8981) Fix English in `note`. (doctrine#8987) Remove detach deprecation entry in UPGRADE.md (doctrine#8978) Bump to PHPStan 0.12.98 and Psalm 4.10.0 (doctrine#8979) Signed-off-by: Alexander M. Turek <me@derrabus.de>
2 parents be2208f + 316ba5f commit 7abd106

10 files changed

+175
-234
lines changed

UPGRADE.md

+3-11
Original file line numberDiff line numberDiff line change
@@ -179,24 +179,16 @@ The `Doctrine\ORM\Version` class is now deprecated and will be removed in Doctri
179179
please refrain from checking the ORM version at runtime or use
180180
[ocramius/package-versions](https://github.com/Ocramius/PackageVersions/).
181181

182-
## Deprecated `EntityManager#merge()` and `EntityManager#detach()` methods
182+
## Deprecated `EntityManager#merge()` method
183183

184-
Merge and detach semantics were a poor fit for the PHP "share-nothing" architecture.
185-
In addition to that, merging/detaching caused multiple issues with data integrity
184+
Merge semantics was a poor fit for the PHP "share-nothing" architecture.
185+
In addition to that, merging caused multiple issues with data integrity
186186
in the managed entity graph, which was constantly spawning more edge-case bugs/scenarios.
187187

188188
The following API methods were therefore deprecated:
189189

190190
* `EntityManager#merge()`
191-
* `EntityManager#detach()`
192191
* `UnitOfWork#merge()`
193-
* `UnitOfWork#detach()`
194-
195-
Users are encouraged to migrate `EntityManager#detach()` calls to `EntityManager#clear()`.
196-
197-
In order to maintain performance on batch processing jobs, it is endorsed to enable
198-
the second level cache (http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/second-level-cache.html)
199-
on entities that are frequently reused across multiple `EntityManager#clear()` calls.
200192

201193
An alternative to `EntityManager#merge()` will not be provided by ORM 3.0, since the merging
202194
semantics should be part of the business domain rather than the persistence domain of an

composer.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@
3939
"doctrine/annotations": "^1.13",
4040
"doctrine/coding-standard": "^9.0",
4141
"phpbench/phpbench": "^0.16.10 || ^1.0",
42-
"phpstan/phpstan": "0.12.96",
42+
"phpstan/phpstan": "0.12.98",
4343
"phpunit/phpunit": "^7.5 || ^8.5 || ^9.4",
4444
"squizlabs/php_codesniffer": "3.6.0",
4545
"symfony/cache": "^4.4 || ^5.2",
4646
"symfony/yaml": "^3.4 || ^4.0 || ^5.0 || ^6.0",
47-
"vimeo/psalm": "4.9.3"
47+
"vimeo/psalm": "4.10.0"
4848
},
4949
"conflict": {
5050
"doctrine/annotations": "<1.13 || >= 2.0"

docs/en/reference/working-with-objects.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Work that have not yet been persisted are lost.
2727

2828
.. note::
2929

30-
Doctrine does NEVER touch the public API of methods in your entity
30+
Doctrine NEVER touches the public API of methods in your entity
3131
classes (like getters and setters) nor the constructor method.
3232
Instead, it uses reflection to get/set data from/to your entity objects.
3333
When Doctrine fetches data from DB and saves it back,

psalm-baseline.xml

+2-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<files psalm-version="4.9.3@4c262932602b9bbab5020863d1eb22d49de0dbf4">
2+
<files psalm-version="4.10.0@916b098b008f6de4543892b1e0651c1c3b92cbfa">
33
<file src="lib/Doctrine/ORM/AbstractQuery.php">
44
<DeprecatedClass occurrences="1">
55
<code>IterableResult</code>
@@ -460,14 +460,12 @@
460460
<DeprecatedClass occurrences="2">
461461
<code>ProxyFactory</code>
462462
</DeprecatedClass>
463-
<DeprecatedMethod occurrences="7">
463+
<DeprecatedMethod occurrences="5">
464464
<code>getAutoGenerateProxyClasses</code>
465465
<code>getMetadataCacheImpl</code>
466466
<code>getProxyDir</code>
467467
<code>getProxyNamespace</code>
468468
<code>merge</code>
469-
<code>setCacheDriver</code>
470-
<code>setCacheDriver</code>
471469
</DeprecatedMethod>
472470
<DocblockTypeContradiction occurrences="9">
473471
<code>$entityName !== null &amp;&amp; ! is_string($entityName)</code>
@@ -3862,9 +3860,6 @@
38623860
<code>new ClassLoader('Symfony\Component', $directory . '/Doctrine')</code>
38633861
<code>new YamlDriver($paths)</code>
38643862
</DeprecatedClass>
3865-
<DeprecatedMethod occurrences="1">
3866-
<code>setMetadataCacheImpl</code>
3867-
</DeprecatedMethod>
38683863
<UnresolvableInclude occurrences="1">
38693864
<code>require_once $directory . '/Doctrine/Common/ClassLoader.php'</code>
38703865
</UnresolvableInclude>

tests/Doctrine/Tests/ORM/Cache/AbstractRegionTest.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Doctrine\Tests\ORM\Cache;
66

7+
use Doctrine\Common\Cache\Cache;
78
use Doctrine\Common\Cache\Psr6\DoctrineProvider;
89
use Doctrine\ORM\Cache\Region;
910
use Doctrine\Tests\Mocks\CacheEntryMock;
@@ -19,7 +20,7 @@ abstract class AbstractRegionTest extends OrmFunctionalTestCase
1920
/** @var Region */
2021
protected $region;
2122

22-
/** @var ArrayCache */
23+
/** @var Cache */
2324
protected $cache;
2425

2526
protected function setUp(): void

tests/Doctrine/Tests/ORM/Cache/DefaultRegionTest.php

+69-78
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@
66

77
use BadMethodCallException;
88
use Doctrine\Common\Cache\Cache;
9-
use Doctrine\Common\Cache\CacheProvider;
109
use Doctrine\Common\Cache\Psr6\DoctrineProvider;
1110
use Doctrine\ORM\Cache\CollectionCacheEntry;
1211
use Doctrine\ORM\Cache\Region;
1312
use Doctrine\ORM\Cache\Region\DefaultRegion;
1413
use Doctrine\Tests\Mocks\CacheEntryMock;
1514
use Doctrine\Tests\Mocks\CacheKeyMock;
15+
use Psr\Cache\CacheItemInterface;
16+
use Psr\Cache\CacheItemPoolInterface;
1617
use Symfony\Component\Cache\Adapter\ArrayAdapter;
1718

1819
use function assert;
19-
use function class_exists;
2020

2121
/**
2222
* @group DDC-2183
@@ -36,15 +36,11 @@ public function testGetters(): void
3636

3737
public function testSharedRegion(): void
3838
{
39-
if (! class_exists(ArrayCache::class)) {
40-
self::markTestSkipped('Test only applies with doctrine/cache 1.x');
41-
}
42-
4339
$cache = new SharedArrayCache();
4440
$key = new CacheKeyMock('key');
4541
$entry = new CacheEntryMock(['value' => 'foo']);
46-
$region1 = new DefaultRegion('region1', $cache->createChild());
47-
$region2 = new DefaultRegion('region2', $cache->createChild());
42+
$region1 = new DefaultRegion('region1', DoctrineProvider::wrap($cache->createChild()));
43+
$region2 = new DefaultRegion('region2', DoctrineProvider::wrap($cache->createChild()));
4844

4945
self::assertFalse($region1->contains($key));
5046
self::assertFalse($region2->contains($key));
@@ -135,76 +131,71 @@ public function corruptedDataDoesNotLeakIntoApplicationWhenGettingMultipleEntrie
135131
}
136132
}
137133

138-
if (class_exists(ArrayCache::class)) {
139-
/**
140-
* Cache provider that offers child cache items (sharing the same array)
141-
*
142-
* Declared as a different class for readability purposes and kept in this file
143-
* to keep its monstrosity contained.
144-
*
145-
* @internal
146-
*/
147-
final class SharedArrayCache extends ArrayCache
134+
/**
135+
* Cache provider that offers child cache items (sharing the same array)
136+
*
137+
* Declared as a different class for readability purposes and kept in this file
138+
* to keep its monstrosity contained.
139+
*
140+
* @internal
141+
*/
142+
final class SharedArrayCache extends ArrayAdapter
143+
{
144+
public function createChild(): CacheItemPoolInterface
148145
{
149-
public function createChild(): Cache
150-
{
151-
return new class ($this) extends CacheProvider {
152-
/** @var ArrayCache */
153-
private $parent;
154-
155-
public function __construct(ArrayCache $parent)
156-
{
157-
$this->parent = $parent;
158-
}
159-
160-
/**
161-
* {@inheritDoc}
162-
*/
163-
protected function doFetch($id)
164-
{
165-
return $this->parent->doFetch($id);
166-
}
167-
168-
/**
169-
* {@inheritDoc}
170-
*/
171-
protected function doContains($id)
172-
{
173-
return $this->parent->doContains($id);
174-
}
175-
176-
/**
177-
* {@inheritDoc}
178-
*/
179-
protected function doSave($id, $data, $lifeTime = 0)
180-
{
181-
return $this->parent->doSave($id, $data, $lifeTime);
182-
}
183-
184-
/**
185-
* {@inheritDoc}
186-
*/
187-
protected function doDelete($id)
188-
{
189-
return $this->parent->doDelete($id);
190-
}
191-
192-
/**
193-
* {@inheritDoc}
194-
*/
195-
protected function doFlush()
196-
{
197-
return $this->parent->doFlush();
198-
}
199-
200-
/**
201-
* {@inheritDoc}
202-
*/
203-
protected function doGetStats()
204-
{
205-
return $this->parent->doGetStats();
206-
}
207-
};
208-
}
146+
return new class ($this) implements CacheItemPoolInterface {
147+
/** @var CacheItemPoolInterface */
148+
private $parent;
149+
150+
public function __construct(CacheItemPoolInterface $parent)
151+
{
152+
$this->parent = $parent;
153+
}
154+
155+
public function getItem($key): CacheItemInterface
156+
{
157+
return $this->parent->getItem($key);
158+
}
159+
160+
public function getItems(array $keys = []): iterable
161+
{
162+
return $this->parent->getItems($keys);
163+
}
164+
165+
public function hasItem($key): bool
166+
{
167+
return $this->parent->hasItem($key);
168+
}
169+
170+
public function clear(): bool
171+
{
172+
return $this->parent->clear();
173+
}
174+
175+
public function deleteItem($key): bool
176+
{
177+
return $this->parent->deleteItem($key);
178+
}
179+
180+
public function deleteItems(array $keys): bool
181+
{
182+
return $this->parent->deleteItems($keys);
183+
}
184+
185+
public function save(CacheItemInterface $item): bool
186+
{
187+
return $this->parent->save($item);
188+
}
189+
190+
public function saveDeferred(CacheItemInterface $item): bool
191+
{
192+
return $this->parent->saveDeferred($item);
193+
}
194+
195+
public function commit(): bool
196+
{
197+
return $this->parent->commit();
198+
}
199+
};
209200
}
210201
}

0 commit comments

Comments
 (0)