Files
michaelschiemer/tests/debug/debug-cache-key.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

68 lines
2.1 KiB
PHP

<?php
declare(strict_types=1);
require_once __DIR__ . '/../../vendor/autoload.php';
use App\Framework\Context\ExecutionContext;
use App\Framework\Core\PathProvider;
echo "=== Debug Cache Key Generation ===\n\n";
$basePath = dirname(__DIR__, 2);
$pathProvider = new PathProvider($basePath);
$currentContext = ExecutionContext::detect();
$contextName = $currentContext->getType()->value;
echo "Base Path: {$basePath}\n";
echo "Context Name: {$contextName}\n";
echo "getBasePath(): {$pathProvider->getBasePath()}\n";
// Mein Cache-Key
$myCacheKey = "discovery:discovery_full_" . md5($contextName . ':' . $pathProvider->getBasePath());
echo "My Cache Key: {$myCacheKey}\n";
// Versuche den Cache-Key aus dem Log zu reproduzieren
$expectedKey = "discovery:discovery_full_76dba56b323a5c0dc136e63ace86fce6";
echo "Expected Key: {$expectedKey}\n";
echo "Keys Match: " . ($myCacheKey === $expectedKey ? 'YES' : 'NO') . "\n";
// Versuche verschiedene Variationen
$variation1 = "discovery:discovery_full_" . md5($contextName);
echo "Variation 1 (context only): {$variation1}\n";
$variation2 = "discovery:discovery_full_" . md5($pathProvider->getBasePath());
echo "Variation 2 (path only): {$variation2}\n";
$variation3 = "discovery:discovery_full_" . md5($basePath);
echo "Variation 3 (base path): {$variation3}\n";
// Hash-Prüfung für verschiedene Ansätze
$targetHash = "76dba56b323a5c0dc136e63ace86fce6";
echo "\nTarget Hash: {$targetHash}\n";
// Mein aktueller Ansatz
$defaultPaths = [$basePath . '/src'];
$pathsHash = md5(implode('|', $defaultPaths));
echo "Current approach: {$pathsHash}\n";
// Teste getSourcePath()
echo "getSourcePath(): {$pathProvider->getSourcePath()}\n";
// Teste verschiedene Path-Kombinationen
$testCombinations = [
[$pathProvider->getSourcePath()],
[$basePath . '/src'],
[$basePath . '/src', $basePath . '/app'],
['/src'],
['src'],
[$basePath],
];
foreach ($testCombinations as $i => $paths) {
$hash = md5(implode('|', $paths));
$match = ($hash === $targetHash) ? '✅ MATCH!' : '';
echo "Test $i (" . implode('|', $paths) . "): {$hash} {$match}\n";
}