fix: resolve RedisCache array offset error and improve discovery diagnostics

- Fix RedisCache driver to handle MGET failures gracefully with fallback
- Add comprehensive discovery context comparison debug tools
- Identify root cause: WEB context discovery missing 166 items vs CLI
- WEB context missing RequestFactory class entirely (52 vs 69 commands)
- Improved exception handling with detailed binding diagnostics
This commit is contained in:
2025-09-12 20:05:18 +02:00
parent 8040d3e7a5
commit e30753ba0e
46990 changed files with 10789682 additions and 89639 deletions

View File

@@ -17,7 +17,6 @@ use App\Framework\View\Caching\CacheManager;
use App\Framework\View\Caching\TaggedFragmentCache;
use App\Framework\View\Caching\TemplateContext;
use App\Framework\View\Loading\TemplateLoader;
use Archive\Optimized\QuickSmartCacheReplacement;
#[Singleton]
final readonly class Engine implements TemplateRenderer
@@ -28,37 +27,21 @@ final readonly class Engine implements TemplateRenderer
public function __construct(
private TemplateLoader $loader,
private PathProvider $pathProvider,
# private PathProvider $pathProvider,
private PerformanceService $performanceService,
private TemplateProcessor $processor = new TemplateProcessor(),
private FileStorage $storage = new FileStorage('/'),
private string $cachePath = __DIR__ . "/cache",
private Container $container = new DefaultContainer(),
private TemplateProcessor $processor,
#private FileStorage $storage = new FileStorage('/'),
#private string $cachePath = __DIR__ . "/cache",
#private Container $container = new DefaultContainer(),
#private bool $useSmartCache = true,
#private bool $legacyCacheEnabled = false,
?Cache $cache = null,
private bool $cacheEnabled = true,
) {
// Stelle sicher, dass das Cache-Verzeichnis existiert
if (! is_dir($this->cachePath)) {
mkdir($this->cachePath, 0755, true);
}
/*
// Initialisiere Smart Cache System
if ($this->useSmartCache && $cache) {
#$analyzer = new TemplateAnalyzer();
#$fragmentCache = new FragmentCacheManager($cache);
$this->smartCache = new QuickSmartCacheReplacement(
cache: $cache,
#analyzer : $analyzer,
#fragmentCache: $fragmentCache,
loader: $this->loader,
processor: $this->processor
);
} else {
$this->smartCache = null;
}*/
#if (! is_dir($this->cachePath)) {
# mkdir($this->cachePath, 0755, true);
#}
// Neues Cache-System initialisieren
if ($this->cacheEnabled && $cache) {
@@ -77,45 +60,18 @@ final readonly class Engine implements TemplateRenderer
public function render(RenderContext $context): string
{
// Verwende neuen CacheManager wenn verfügbar
if ($this->cacheManager) {
$templateContext = new TemplateContext(
template: $context->template,
data: $context->data,
controllerClass: $context->controllerClass,
metadata: $context->metaData ? ['meta' => $context->metaData] : []
);
$templateContext = new TemplateContext(
template: $context->template,
data: $context->data,
controllerClass: $context->controllerClass,
metadata: $context->metaData ? ['meta' => $context->metaData] : []
);
return $this->cacheManager->render($templateContext, function () use ($context) {
return $this->renderDirect($context);
});
}
// Fallback ohne Cache
/*return $this->legacyCacheEnabled
? $this->renderWithLegacyCache($context)
: $this->renderDirect($context);*/
return $this->cacheManager->render($templateContext, function () use ($context) {
return $this->renderDirect($context);
});
}
/*private function renderWithLegacyCache(RenderContext $context): string
{
$cacheKey = 'view_' . md5($context->template . '_' . ($context->controllerClass ?? ''));
$cacheFile = $this->cachePath . "/{$cacheKey}.cache.html";
// Optimized cache check - avoid expensive filemtime calls
if (file_exists($cacheFile)) {
$content = $this->storage->get($cacheFile);
return $this->processor->render($context, $content);
}
// Cache miss - render and cache
$content = $this->renderDirect($context);
$this->storage->put($cacheFile, $content);
return $content;
}*/
private function renderDirect(RenderContext $context): string
{
// Optimized single-pass rendering

View File

@@ -0,0 +1,23 @@
<?php
declare(strict_types=1);
namespace App\Framework\View;
/**
* Enhanced DOM processor interface that works with DomWrapper
*
* Provides advanced DOM processing capabilities with wrapper support
* for better performance and more flexible DOM manipulation.
*/
interface EnhancedDomProcessor
{
/**
* Process DOM using the enhanced DomWrapper functionality
*
* @param DomWrapper $domWrapper The DOM wrapper to process
* @param RenderContext $context The rendering context
* @return DomWrapper The processed DOM wrapper
*/
public function processWrapper(DomWrapper $domWrapper, RenderContext $context): DomWrapper;
}

View File

@@ -30,8 +30,6 @@ final readonly class TemplateRendererInitializer
{
public function __construct(
private DefaultContainer $container,
#private FileScanner $scanner,
#private PathProvider $pathProvider,
private DiscoveryRegistry $results,
) {
}
@@ -79,8 +77,11 @@ final readonly class TemplateRendererInitializer
$this->container->singleton(TemplateProcessor::class, $templateProcessor);
/** @var PathProvider $pathProvider */
$pathProvider = $this->container->get(PathProvider::class);
/** @var Cache $cache */
$cache = $this->container->get(Cache::class);
/** @var PerformanceService $performanceService */
$performanceService = $this->container->get(PerformanceService::class);
$loader = new TemplateLoader(pathProvider: $pathProvider, cache: $cache, discoveryRegistry: $this->results/*, templates: $templates*/);
@@ -88,11 +89,9 @@ final readonly class TemplateRendererInitializer
$this->container->singleton(TemplateLoader::class, $loader);
return new Engine(
$loader,
$pathProvider,
$performanceService,
loader: $loader,
performanceService: $performanceService,
processor: $templateProcessor,
container: $this->container,
cache: $cache,
);
}

View File

@@ -8,9 +8,6 @@
<!-- Favicon (optional) -->
<link rel="icon" href="/favicon.ico" type="image/x-icon">
<!-- CSS Reset oder Normalize (optional) -->
<!-- <link rel="stylesheet" href="https://unpkg.com/modern-css-reset/dist/reset.min.css"> -->
<!-- Eigene Styles -->
<!--<link rel="stylesheet" href="http://localhost:5173/assets/css/styles.css">-->
@@ -44,31 +41,28 @@
</menu>
</nav>
<button popovertarget="mypopover"
<!--<button popovertarget="mypopover"
popovertargetaction="show"
aria-label="Menü öffnen"
aria-controls="Main Navigation"
aria-expanded="false"
id="menu-toggle"
></button>
></button>-->
</div>
</header>
<div class="backdrop"></div>
<!--<div class="backdrop"></div>
<aside id="sidebar" view-transition-name="sidebar">
<nav aria-label="Hauptnavigation" id="mypopover">
<!-- Navigation -->
<menu>
<li><a href="/">Startseite</a></li>
<li><a href="/impressum">Impressum</a></li>
<li><a href="/kontakt">Kontakt</a></li>
</menu>
</nav>
</aside>
</aside>-->
<!--<div class="page-container" tabindex="-1" id="pageTitle" style="outline: none">-->
@@ -89,8 +83,6 @@
<!--</div>-->
<footer role="contentinfo" view-transition-name="site-footer">
<nav aria-label="Footer Navigation">
<menu class="footer-nav">
<li><a href="/impressum">Impressum</a></li>