Skip to content

Commit 99b38c3

Browse files
fix(core): change caching logic for validation attributes
1 parent a5728ea commit 99b38c3

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

framework/core/src/Foundation/AbstractValidator.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,14 @@ protected function getAttributeNames()
9696
{
9797
$cache = resolve(Cache::class);
9898

99-
if ($cache->get(self::$CORE_VALIDATION_CACHE_KEY) !== null) {
100-
return $cache->get(self::$CORE_VALIDATION_CACHE_KEY);
99+
$cacheKey = sprintf(
100+
'core.validation.attributes.%s.%s',
101+
$this->translator->getLocale(),
102+
static::class
103+
);
104+
105+
if ($cached = $cache->get($cacheKey)) {
106+
return $cached;
101107
}
102108

103109
$extId = $this->getClassExtensionId();
@@ -108,7 +114,7 @@ protected function getAttributeNames()
108114
$attributeNames[$attribute] = $this->translator->trans($key);
109115
}
110116

111-
$cache->forever(self::$CORE_VALIDATION_CACHE_KEY, $attributeNames);
117+
$cache->forever($cacheKey, $attributeNames);
112118

113119
return $attributeNames;
114120
}

0 commit comments

Comments
 (0)