Files
michaelschiemer/tests/debug/debug-cache-detailed.php
Michael Schiemer 55a330b223 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
2025-08-11 20:13:26 +02:00

81 lines
2.7 KiB
PHP

<?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\Performance\EnhancedPerformanceCollector;
use App\Framework\Performance\MemoryMonitor;
echo "=== Detailed Cache Analysis ===\n\n";
$basePath = '/var/www/html';
$pathProvider = new PathProvider($basePath);
$clock = new SystemClock();
$highResClock = new SystemHighResolutionClock();
$memoryMonitor = new MemoryMonitor();
$performanceCollector = new EnhancedPerformanceCollector($clock, $highResClock, $memoryMonitor, false);
$container = new DefaultContainer();
$cacheInitializer = new CacheInitializer($performanceCollector, $container);
$cache = $cacheInitializer();
$defaultPaths = [$pathProvider->getSourcePath()];
$cacheKey = DiscoveryCacheIdentifiers::fullDiscoveryKey($defaultPaths);
$cachedItem = $cache->get($cacheKey);
if ($cachedItem !== null && $cachedItem->value !== null) {
echo "✅ Cache found\n";
$data = $cachedItem->value;
echo "Cache Value Type: " . gettype($data) . "\n";
if (is_object($data)) {
echo "Object Class: " . get_class($data) . "\n";
echo "Object Count: " . $data->count() . "\n";
} elseif (is_string($data)) {
echo "String Length: " . strlen($data) . "\n";
echo "First 200 chars: " . substr($data, 0, 200) . "\n";
// Try to decode as JSON
$decoded = json_decode($data, true);
if (json_last_error() === JSON_ERROR_NONE) {
echo "✅ Valid JSON detected\n";
echo "JSON Keys: " . implode(', ', array_keys($decoded)) . "\n";
} else {
echo "❌ Not valid JSON\n";
}
} elseif (is_array($data)) {
echo "Array Keys: " . implode(', ', array_keys($data)) . "\n";
foreach ($data as $key => $value) {
echo "\n--- $key ---\n";
echo "Type: " . gettype($value) . "\n";
if (is_array($value)) {
echo "Array keys: " . implode(', ', array_keys($value)) . "\n";
if ($key === 'attributes' && isset($value['mappings'])) {
echo "Mappings count: " . count($value['mappings']) . "\n";
echo "First 3 mappings keys: " . implode(', ', array_slice(array_keys($value['mappings']), 0, 3)) . "\n";
}
if ($key === 'routes' && isset($value['routes'])) {
echo "Routes count: " . count($value['routes']) . "\n";
}
}
}
}
} else {
echo "❌ No cache found\n";
}
echo "\nDone.\n";