Files
michaelschiemer/force_web_discovery.php
Michael Schiemer e30753ba0e 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
2025-09-12 20:05:18 +02:00

77 lines
2.6 KiB
PHP

<?php
declare(strict_types=1);
require __DIR__ . '/vendor/autoload.php';
use App\Framework\Context\ExecutionContext;
use App\Framework\Discovery\DiscoveryServiceBootstrapper;
use App\Framework\Cache\Cache;
use App\Framework\Cache\CacheKey;
use App\Framework\Discovery\Cache\DiscoveryCacheIdentifiers;
use App\Framework\DateTime\SystemClock;
use App\Framework\Core\PathProvider;
use App\Framework\DI\DefaultContainer;
echo "=== Force Web Discovery Rebuild ===\n";
// Manually set execution context to WEB
$_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0 (compatible)';
$_SERVER['SERVER_NAME'] = 'localhost';
$_SERVER['REQUEST_METHOD'] = 'GET';
$_SERVER['REQUEST_URI'] = '/';
// Force detection as web context
$context = ExecutionContext::detect();
echo "Detected context: " . $context->getType()->value . "\n";
try {
// Create container
$container = new DefaultContainer();
$clock = new SystemClock();
$pathProvider = new PathProvider(__DIR__);
$container->instance(\App\Framework\DateTime\Clock::class, $clock);
$container->instance(\App\Framework\Core\PathProvider::class, $pathProvider);
// Create cache (simplified)
$cache = new \App\Framework\Cache\Driver\ArrayCache();
$container->instance(Cache::class, $cache);
// Clear web-specific cache
$defaultPaths = [$pathProvider->getSourcePath()];
$contextString = $context->getType()->value;
$cacheKey = DiscoveryCacheIdentifiers::fullDiscoveryKey($defaultPaths, $contextString);
echo "Clearing cache key: " . $cacheKey->toString() . "\n";
$cache->forget($cacheKey);
// Force discovery rebuild
$bootstrapper = new DiscoveryServiceBootstrapper($container, $clock);
$registry = $bootstrapper->bootstrap();
echo "Discovery completed with " . count($registry) . " total items\n";
// Check for RequestFactory
$initializers = $registry->initializers;
$requestFactoryFound = false;
foreach ($initializers->getAllClasses() as $className) {
if (str_contains($className, 'RequestFactory')) {
echo "Found RequestFactory: $className\n";
$methods = $initializers->getByClass($className);
foreach ($methods as $method) {
echo " Method: " . $method->method . "\n";
}
$requestFactoryFound = true;
}
}
if (!$requestFactoryFound) {
echo "❌ RequestFactory initializer not found in WEB context!\n";
} else {
echo "✅ RequestFactory found in web discovery\n";
}
} catch (Throwable $e) {
echo "ERROR: " . $e->getMessage() . "\n";
echo "FILE: " . $e->getFile() . ":" . $e->getLine() . "\n";
}