From 38b97592e31fd23314b6d224930aadc8c1902097 Mon Sep 17 00:00:00 2001 From: James Hulse Date: Tue, 20 Feb 2024 08:32:04 +1300 Subject: [PATCH] Backport cache fix to v3 --- src/Support/Caching/CachedDataConfig.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/Support/Caching/CachedDataConfig.php b/src/Support/Caching/CachedDataConfig.php index 9a3b527d..fbd504e2 100644 --- a/src/Support/Caching/CachedDataConfig.php +++ b/src/Support/Caching/CachedDataConfig.php @@ -20,7 +20,21 @@ public function __construct() public function getDataClass(string $class): DataClass { - return $this->cache?->getDataClass($class) ?? parent::getDataClass($class); + if (array_key_exists($class, $this->dataClasses)) { + return $this->dataClasses[$class]; + } + + if ($this->cache === null) { + return parent::getDataClass($class); + } + + $dataClass = $this->cache->getDataClass($class); + + if ($dataClass === null) { + return parent::getDataClass($class); + } + + return $this->dataClasses[$class] = $dataClass; } public function setCache(DataStructureCache $cache): self