Enable Discovery debug logging for production troubleshooting
- Add DISCOVERY_LOG_LEVEL=debug - Add DISCOVERY_SHOW_PROGRESS=true - Temporary changes for debugging InitializerProcessor fixes on production
This commit is contained in:
@@ -1,24 +1,29 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Framework\View\Caching\Strategies;
|
||||
|
||||
use App\Framework\Cache\Cache;
|
||||
use App\Framework\Cache\CacheKey;
|
||||
use App\Framework\View\Caching\TemplateContext;
|
||||
|
||||
final readonly class FullPageCacheStrategy implements ViewCacheStrategy
|
||||
{
|
||||
public function __construct(private Cache $cache) {}
|
||||
public function __construct(private Cache $cache)
|
||||
{
|
||||
}
|
||||
|
||||
public function shouldCache(TemplateContext $context): bool
|
||||
{
|
||||
// Keine User-spezifischen Daten
|
||||
return !$this->hasUserData($context->data) &&
|
||||
!$this->hasVolatileData($context->data);
|
||||
return ! $this->hasUserData($context->data) &&
|
||||
! $this->hasVolatileData($context->data);
|
||||
}
|
||||
|
||||
public function generateKey(TemplateContext $context): string
|
||||
public function generateKey(TemplateContext $context): CacheKey
|
||||
{
|
||||
return "page:{$context->template}:" . md5(serialize($this->getNonVolatileData($context->data)));
|
||||
return CacheKey::fromString("page:{$context->template}:" . md5(serialize($this->getNonVolatileData($context->data))));
|
||||
}
|
||||
|
||||
public function getTtl(TemplateContext $context): int
|
||||
@@ -34,26 +39,36 @@ final readonly class FullPageCacheStrategy implements ViewCacheStrategy
|
||||
private function hasUserData(array $data): bool
|
||||
{
|
||||
$userKeys = ['user', 'auth', 'session', 'current_user'];
|
||||
return !empty(array_intersect(array_keys($data), $userKeys));
|
||||
|
||||
return ! empty(array_intersect(array_keys($data), $userKeys));
|
||||
}
|
||||
|
||||
private function hasVolatileData(array $data): bool
|
||||
{
|
||||
$volatileKeys = ['csrf_token', '_token', 'flash', 'errors', 'timestamp', 'now'];
|
||||
return !empty(array_intersect(array_keys($data), $volatileKeys));
|
||||
|
||||
return ! empty(array_intersect(array_keys($data), $volatileKeys));
|
||||
}
|
||||
|
||||
private function getNonVolatileData(array $data): array
|
||||
{
|
||||
$volatileKeys = ['csrf_token', '_token', 'flash', 'errors', 'timestamp', 'now', 'user', 'auth', 'session'];
|
||||
|
||||
return array_diff_key($data, array_flip($volatileKeys));
|
||||
}
|
||||
|
||||
private function getPageType(string $template): string
|
||||
{
|
||||
if (str_contains($template, 'layout')) return 'layout';
|
||||
if (str_contains($template, 'static')) return 'static';
|
||||
if (str_contains($template, 'page')) return 'content';
|
||||
if (str_contains($template, 'layout')) {
|
||||
return 'layout';
|
||||
}
|
||||
if (str_contains($template, 'static')) {
|
||||
return 'static';
|
||||
}
|
||||
if (str_contains($template, 'page')) {
|
||||
return 'content';
|
||||
}
|
||||
|
||||
return 'default';
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user