Skip to content

Commit

Permalink
Merge pull request #4839 from mhsdesign/bugfix/4595-avoid-parse-parti…
Browse files Browse the repository at this point in the history
…als-cache-to-crash-in-rare-case

BUGFIX: Fusion avoid error parser cache to crash if cache is broken
  • Loading branch information
mhsdesign authored Feb 5, 2024
2 parents 43d2f34 + 7adf0dd commit 0a234a6
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions Neos.Fusion/Classes/Core/Cache/ParserCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,16 @@ public function cacheForDsl(string $identifier, string $code, \Closure $generate

private function cacheForIdentifier(string $identifier, \Closure $generateValueToCache): mixed
{
if ($this->parsePartialsCache->has($identifier)) {
return $this->parsePartialsCache->get($identifier);
$value = $this->parsePartialsCache->get($identifier);
if ($value !== false) {
return $value;
}
$value = $generateValueToCache();
$this->parsePartialsCache->set($identifier, $value);
if ($value !== false) {
// in the rare edge-case of a fusion dsl returning `false` we cannot cache it,
// as the above get would be ignored. This is an acceptable compromise.
$this->parsePartialsCache->set($identifier, $value);
}
return $value;
}

Expand Down

0 comments on commit 0a234a6

Please sign in to comment.