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:
84
tests/debug/test-web-cache.php
Normal file
84
tests/debug/test-web-cache.php
Normal file
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
require_once '/var/www/html/vendor/autoload.php';
|
||||
|
||||
use App\Framework\Cache\CacheInitializer;
|
||||
use App\Framework\Core\PathProvider;
|
||||
use App\Framework\DateTime\SystemClock;
|
||||
use App\Framework\DateTime\SystemHighResolutionClock;
|
||||
use App\Framework\DI\DefaultContainer;
|
||||
use App\Framework\Discovery\Cache\DiscoveryCacheIdentifiers;
|
||||
use App\Framework\Discovery\Results\DiscoveryRegistry;
|
||||
use App\Framework\Performance\EnhancedPerformanceCollector;
|
||||
use App\Framework\Performance\MemoryMonitor;
|
||||
|
||||
echo "=== Testing Web Context Cache ===\n\n";
|
||||
|
||||
// Setup wie im Web-Container
|
||||
$basePath = '/var/www/html';
|
||||
$pathProvider = new PathProvider($basePath);
|
||||
$clock = new SystemClock();
|
||||
|
||||
// Create cache
|
||||
$highResClock = new SystemHighResolutionClock();
|
||||
$memoryMonitor = new MemoryMonitor();
|
||||
$performanceCollector = new EnhancedPerformanceCollector($clock, $highResClock, $memoryMonitor, false);
|
||||
$container = new DefaultContainer();
|
||||
$cacheInitializer = new CacheInitializer($performanceCollector, $container);
|
||||
$cache = $cacheInitializer();
|
||||
|
||||
// Generate cache key for web context
|
||||
$defaultPaths = [$pathProvider->getSourcePath()];
|
||||
$cacheKey = DiscoveryCacheIdentifiers::fullDiscoveryKey($defaultPaths);
|
||||
|
||||
echo "Checking Web Context Cache Key: {$cacheKey->toString()}\n";
|
||||
echo "Source path: {$pathProvider->getSourcePath()}\n\n";
|
||||
|
||||
// Check cache
|
||||
$cachedItem = $cache->get($cacheKey);
|
||||
|
||||
if ($cachedItem !== null) {
|
||||
echo "✅ CACHE HIT! Registry found in web cache.\n";
|
||||
if ($cachedItem->value !== null) {
|
||||
echo "Value type: " . gettype($cachedItem->value) . "\n";
|
||||
|
||||
if (is_object($cachedItem->value)) {
|
||||
echo "Registry class: " . get_class($cachedItem->value) . "\n";
|
||||
|
||||
if ($cachedItem->value instanceof \App\Framework\Discovery\Results\DiscoveryRegistry) {
|
||||
$registry = $cachedItem->value;
|
||||
echo "Routes count: " . $registry->routes->count() . "\n";
|
||||
echo "Attributes count: " . count($registry->attributes->getAllTypes()) . "\n";
|
||||
echo "Interfaces count: " . $registry->interfaces->count() . "\n";
|
||||
echo "Templates count: " . $registry->templates->count() . "\n";
|
||||
} else {
|
||||
echo "⚠️ Object is not DiscoveryRegistry: " . get_class($cachedItem->value) . "\n";
|
||||
}
|
||||
} else {
|
||||
echo "⚠️ Value is not an object: " . gettype($cachedItem->value) . "\n";
|
||||
if (is_array($cachedItem->value)) {
|
||||
echo "Array keys: " . implode(', ', array_keys($cachedItem->value)) . "\n";
|
||||
|
||||
// Test fromArray conversion
|
||||
echo "\n🔄 Testing fromArray conversion...\n";
|
||||
|
||||
try {
|
||||
$convertedRegistry = DiscoveryRegistry::fromArray($cachedItem->value);
|
||||
echo "✅ Conversion successful!\n";
|
||||
echo "Converted routes count: " . $convertedRegistry->routes->count() . "\n";
|
||||
echo "Converted attributes count: " . count($convertedRegistry->attributes->getAllTypes()) . "\n";
|
||||
} catch (\Exception $e) {
|
||||
echo "❌ Conversion failed: " . $e->getMessage() . "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
echo "⚠️ Registry value is null - deserialization issue?\n";
|
||||
}
|
||||
} else {
|
||||
echo "❌ CACHE MISS! No registry found in web cache.\n";
|
||||
}
|
||||
|
||||
echo "\nDone.\n";
|
||||
Reference in New Issue
Block a user