Skip to content

Commit ac7802e

Browse files
staabmclxmstaab
andauthored
fixed RecordingQueryReflector (#240)
Co-authored-by: Markus Staab <[email protected]>
1 parent ffaadc3 commit ac7802e

File tree

5 files changed

+378
-8702
lines changed

5 files changed

+378
-8702
lines changed

src/QueryReflection/ReflectionCache.php

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
final class ReflectionCache
1414
{
15-
public const SCHEMA_VERSION = 'v4-runtime-config';
15+
public const SCHEMA_VERSION = 'v5-runtime-config-bugfix';
1616

1717
/**
1818
* @var string
@@ -78,9 +78,9 @@ private function lazyReadRecords()
7878
return $this->records;
7979
}
8080

81-
$cache = $this->readCache(true);
82-
if (null !== $cache) {
83-
$this->records = $cache['records'];
81+
$cachedRecords = $this->readCachedRecords(true);
82+
if (null !== $cachedRecords) {
83+
$this->records = $cachedRecords;
8484
} else {
8585
$this->records = [];
8686
}
@@ -90,13 +90,9 @@ private function lazyReadRecords()
9090
}
9191

9292
/**
93-
* @return array{
94-
* records: array<string, array{error?: ?Error, result?: array<QueryReflector::FETCH_TYPE*, ?Type>}>,
95-
* runtimeConfig: array<string, scalar>,
96-
* schemaVersion: string
97-
* }|null
93+
* @return array<string, array{error?: ?Error, result?: array<QueryReflector::FETCH_TYPE*, ?Type>}>|null
9894
*/
99-
private function readCache(bool $useReadLock): ?array
95+
private function readCachedRecords(bool $useReadLock): ?array
10096
{
10197
if (!is_file($this->cacheFile)) {
10298
if (false === file_put_contents($this->cacheFile, '')) {
@@ -127,8 +123,7 @@ private function readCache(bool $useReadLock): ?array
127123
throw new ShouldNotHappenException();
128124
}
129125

130-
// @phpstan-ignore-next-line
131-
return $cache;
126+
return $cache['records'];
132127
}
133128

134129
public function persist(): void
@@ -141,7 +136,7 @@ public function persist(): void
141136
flock(self::$lockHandle, LOCK_EX);
142137

143138
// freshly read the cache as it might have changed in the meantime
144-
$cachedRecords = $this->readCache(false);
139+
$cachedRecords = $this->readCachedRecords(false);
145140

146141
// re-apply all changes to the current cache-state
147142
if (null === $cachedRecords) {

0 commit comments

Comments
 (0)