Skip to content

Commit 7fd477b

Browse files
committed
Merge branch 'hotfix/fix-hash-collision-logic'
2 parents c476281 + 648ada0 commit 7fd477b

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

src/CachedBuilder.php

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -178,17 +178,35 @@ public function cachedValue(array $arguments, string $cacheKey, string $method)
178178
$method
179179
);
180180

181-
if ($result['key'] !== $cacheKey) {
182-
cache()->tags($cacheTags)->forget($hashedCacheKey);
183-
}
184-
185-
$result = $this->retrieveCachedValue(
181+
return $this->preventHashCollision(
182+
$result,
186183
$arguments,
187184
$cacheKey,
188185
$cacheTags,
189186
$hashedCacheKey,
190187
$method
191188
);
189+
}
190+
191+
protected function preventHashCollision(
192+
array $result,
193+
array $arguments,
194+
string $cacheKey,
195+
array $cacheTags,
196+
string $hashedCacheKey,
197+
string $method
198+
) {
199+
if ($result['key'] !== $cacheKey) {
200+
cache()->tags($cacheTags)->forget($hashedCacheKey);
201+
202+
$result = $this->retrieveCachedValue(
203+
$arguments,
204+
$cacheKey,
205+
$cacheTags,
206+
$hashedCacheKey,
207+
$method
208+
);
209+
}
192210

193211
return $result['value'];
194212
}

0 commit comments

Comments
 (0)