Skip to content

EspoCRM – Open Source CRM Application

Merge

Yuriic79e291e83cd
diff --cc application/Espo/Core/Utils/Language.php
index fe215bfa55,c748e45288..0870b181b7
--- a/application/Espo/Core/Utils/Language.php
+++ b/application/Espo/Core/Utils/Language.php
@@@ -453,35 -430,38 +453,39 @@@ class Languag
$cacheKey = $this->getCacheKey($language);
- if (!$this->useCache || !$this->dataCache->has($cacheKey) || $reload) {
+ if (!$reload && $this->useCache && $this->dataCache->has($cacheKey)) {
+ if ($language !== basename($language)) {
+ throw new RuntimeException("Bad language value.");
+ }
+
- $readerParams = ResourceReaderParams
- ::create()
- ->withNoCustom($this->noCustom);
-
- $path = str_replace('{language}', $language, $this->resourcePath);
+ /** @var ?array<string, mixed> $cachedData */
+ $cachedData = $this->dataCache->get($cacheKey);
- $data = $this->resourceReader->readAsArray($path, $readerParams);
+ if ($cachedData !== null) {
+ $this->data[$language] = $cachedData;
- if ($language !== $this->defaultLanguage && !$this->noFallback) {
- /** @var array<string, array<string, mixed>> $data */
- $data = Util::merge($this->getDefaultLanguageData($reload), $data);
+ return $cachedData;
}
+ }
- $this->data[$language] = $data;
+ $readerParams = ResourceReaderParams::create()
+ ->withNoCustom($this->noCustom);
- if ($this->useCache) {
- $this->dataCache->store($cacheKey, $data);
- }
+ $path = str_replace('{language}', $language, $this->resourcePath);
+
+ $data = $this->resourceReader->readAsArray($path, $readerParams);
+
+ if ($language !== $this->defaultLanguage && !$this->noFallback) {
+ /** @var array<string, array<string, mixed>> $data */
+ $data = Util::merge($this->getDefaultLanguageData($reload), $data);
}
- if ($this->useCache) {
- /** @var array<string, mixed> $cachedData */
- $cachedData = $this->dataCache->get($cacheKey);
+ $this->data[$language] = $data;
- $this->data[$language] = $cachedData;
+ if ($this->useCache) {
+ $this->dataCache->store($cacheKey, $data);
}
- return $this->data[$language] ?? [];
+ return $data;
}
}