Skip to content

Commit

Permalink
Call to a member function resolveAssociationEntries() on boolean
Browse files Browse the repository at this point in the history
The following mistakes occur occasionally:

```
Call to a member function resolveAssociationEntries() on boolean {"detail":"[object] (Symfony\\Component\\Debug\\Exception\\FatalThrowableError(code: 0): Call to a member function resolveAssociationEntries() on boolean at /www/vendor/doctrine/orm/lib/Doctrine/ORM/Cache/DefaultQueryCache.php:140)"}
```

On cache miss the parameter `$entityEntry` sometimes will be false. This fixes issue #7266.
  • Loading branch information
umpirsky committed Jul 26, 2019
1 parent d606941 commit 1db9fb2
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/Doctrine/ORM/Cache/DefaultQueryCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public function get(QueryCacheKey $key, ResultSetMapping $rsm, array $hints = []
foreach ($cacheEntry->result as $index => $entry) {
$entityEntry = is_array($entries) ? ($entries[$index] ?? null) : null;

if ($entityEntry === null) {
if (!$entityEntry) {
if ($this->cacheLogger !== null) {
$this->cacheLogger->entityCacheMiss($regionName, $cacheKeys->identifiers[$index]);
}
Expand Down
28 changes: 28 additions & 0 deletions tests/Doctrine/Tests/ORM/Cache/DefaultQueryCacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,34 @@ public function testGetWithAssociation() : void
self::assertEquals('Bar', $result[1]->getName());
}

public function testGetWithAssociationCacheMiss() : void
{
$rsm = new ResultSetMappingBuilder($this->em);
$key = new QueryCacheKey('query.key1', 0);
$entry = new QueryCacheEntry(
[
['identifier' => ['id' => 1]],
['identifier' => ['id' => 2]],
]
);

$this->region->addReturn('get', $entry);

$this->region->addReturn(
'getMultiple',
[
new EntityCacheEntry(Country::class, ['id' => 1, 'name' => 'Foo']),
false,
]
);

$rsm->addRootEntityFromClassMetadata(Country::class, 'c');

$result = $this->queryCache->get($key, $rsm);

self::assertNull($result);
}

public function testCancelPutResultIfEntityPutFails() : void
{
$result = [];
Expand Down

0 comments on commit 1db9fb2

Please sign in to comment.