|
22 | 22 | use Doctrine\ORM\PersistentCollection;
|
23 | 23 | use Doctrine\ORM\Persisters\Entity\EntityPersister;
|
24 | 24 | use Doctrine\ORM\Proxy\DefaultProxyClassNameResolver;
|
| 25 | +use Doctrine\ORM\Query\FilterCollection; |
25 | 26 | use Doctrine\ORM\UnitOfWork;
|
26 | 27 |
|
27 | 28 | use function array_merge;
|
@@ -62,6 +63,9 @@ abstract class AbstractEntityPersister implements CachedEntityPersister
|
62 | 63 | /** @var Cache */
|
63 | 64 | protected $cache;
|
64 | 65 |
|
| 66 | + /** @var FilterCollection */ |
| 67 | + protected $filters; |
| 68 | + |
65 | 69 | /** @var CacheLogger|null */
|
66 | 70 | protected $cacheLogger;
|
67 | 71 |
|
@@ -91,6 +95,7 @@ public function __construct(EntityPersister $persister, Region $region, EntityMa
|
91 | 95 | $this->region = $region;
|
92 | 96 | $this->persister = $persister;
|
93 | 97 | $this->cache = $em->getCache();
|
| 98 | + $this->filters = $em->getFilters(); |
94 | 99 | $this->regionName = $region->getName();
|
95 | 100 | $this->uow = $em->getUnitOfWork();
|
96 | 101 | $this->metadataFactory = $em->getMetadataFactory();
|
@@ -261,7 +266,7 @@ protected function getHash($query, $criteria, ?array $orderBy = null, $limit = n
|
261 | 266 | ? $this->persister->expandCriteriaParameters($criteria)
|
262 | 267 | : $this->persister->expandParameters($criteria);
|
263 | 268 |
|
264 |
| - return sha1($query . serialize($params) . serialize($orderBy) . $limit . $offset); |
| 269 | + return sha1($query . serialize($params) . serialize($orderBy) . $limit . $offset . $this->filters->getHash()); |
265 | 270 | }
|
266 | 271 |
|
267 | 272 | /**
|
@@ -524,7 +529,7 @@ public function loadManyToManyCollection(array $assoc, $sourceEntity, Persistent
|
524 | 529 | }
|
525 | 530 |
|
526 | 531 | $ownerId = $this->uow->getEntityIdentifier($collection->getOwner());
|
527 |
| - $key = $this->buildCollectionCacheKey($assoc, $ownerId); |
| 532 | + $key = $this->buildCollectionCacheKey($assoc, $ownerId, $this->filters->getHash()); |
528 | 533 | $list = $persister->loadCollectionCache($collection, $key);
|
529 | 534 |
|
530 | 535 | if ($list !== null) {
|
@@ -559,7 +564,7 @@ public function loadOneToManyCollection(array $assoc, $sourceEntity, PersistentC
|
559 | 564 | }
|
560 | 565 |
|
561 | 566 | $ownerId = $this->uow->getEntityIdentifier($collection->getOwner());
|
562 |
| - $key = $this->buildCollectionCacheKey($assoc, $ownerId); |
| 567 | + $key = $this->buildCollectionCacheKey($assoc, $ownerId, $this->filters->getHash()); |
563 | 568 | $list = $persister->loadCollectionCache($collection, $key);
|
564 | 569 |
|
565 | 570 | if ($list !== null) {
|
@@ -611,12 +616,13 @@ public function refresh(array $id, $entity, $lockMode = null)
|
611 | 616 | *
|
612 | 617 | * @return CollectionCacheKey
|
613 | 618 | */
|
614 |
| - protected function buildCollectionCacheKey(array $association, $ownerId) |
| 619 | + protected function buildCollectionCacheKey(array $association, $ownerId, string $filterHash) |
615 | 620 | {
|
616 | 621 | return new CollectionCacheKey(
|
617 | 622 | $this->metadataFactory->getMetadataFor($association['sourceEntity'])->rootEntityName,
|
618 | 623 | $association['fieldName'],
|
619 |
| - $ownerId |
| 624 | + $ownerId, |
| 625 | + $filterHash |
620 | 626 | );
|
621 | 627 | }
|
622 | 628 | }
|
0 commit comments