Skip to content

Commit

Permalink
Move language caching into installation cache
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelfolaron committed Jun 6, 2024
1 parent 76cb99d commit 283e0f7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion app/Core/HttpKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 154,11 @@ public function getApplication(): \Leantime\Core\Application
public function getMiddleware(): array
{
return self::dispatch_filter('http_middleware', [
Middleware\StartSession::class,
Middleware\TrustProxies::class,
Middleware\InitialHeaders::class,
Middleware\Installed::class,
Middleware\Updated::class,
Middleware\StartSession::class,
Middleware\RequestRateLimiter::class,
$this->app->make(IncomingRequest::class) instanceof ApiRequest
? Middleware\ApiAuth::class
Expand Down
19 changes: 10 additions & 9 deletions app/Core/Language.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 3,7 @@
namespace Leantime\Core;

use Exception;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Str;
use Symfony\Component\HttpFoundation\Cookie;
use Symfony\Component\HttpFoundation\Response;
Expand Down Expand Up @@ -167,14 168,14 @@ public function isValidLanguage(string $langCode): bool
*/
public function readIni(): array
{
if (session()->exists('cache.language_resources_' . $this->language) && $this->config->debug == 0) {
$this->ini_array = session(['cache.language_resources_' . $this->language => self::dispatch_filter(
if (Cache::store('installation')->has('cache.language_resources_' . $this->language) && $this->config->debug == 0) {
$this->ini_array = Cache::store('installation')->set('cache.language_resources_' . $this->language, self::dispatch_filter(
'language_resources',
session('cache.language_resources_' . $this->language),
Cache::store('installation')->get('cache.language_resources_' . $this->language),
[
'language' => $this->language,
]
)]);
));
return $this->ini_array;
}

Expand Down Expand Up @@ -206,7 207,7 @@ public function readIni(): array
]
);

session(['cache.language_resources_' . $this->language => $this->ini_array]);
Cache::store("installation")->set('cache.language_resources_' . $this->language, $this->ini_array);

return $this->ini_array;
}
Expand Down Expand Up @@ -254,8 255,8 @@ protected function includeOverrides(array $language, string $filepath, bool $for
*/
public function getLanguageList(): bool|array
{
if (session()->exists("cache.langlist")) {
return session("cache.langlist");
if (Cache::store('installation')->has("cache.langlist")) {
return Cache::store('installation')->get("cache.langlist");
}

$langlist = false;
Expand All @@ -276,9 277,9 @@ public function getLanguageList(): bool|array
}

$parsedLangList = self::dispatch_filter('languages', $langlist);
session(["cache.langlist" => $parsedLangList]);
Cache::store('installation')->set("cache.langlist", $parsedLangList);

return session("cache.langlist");
return $parsedLangList;
}

/**
Expand Down

0 comments on commit 283e0f7

Please sign in to comment.