Resolved multiple critical discovery system issues: ## Discovery System Fixes - Fixed console commands not being discovered on first run - Implemented fallback discovery for empty caches - Added context-aware caching with separate cache keys - Fixed object serialization preventing __PHP_Incomplete_Class ## Cache System Improvements - Smart caching that only caches meaningful results - Separate caches for different execution contexts (console, web, test) - Proper array serialization/deserialization for cache compatibility - Cache hit logging for debugging and monitoring ## Object Serialization Fixes - Fixed DiscoveredAttribute serialization with proper string conversion - Sanitized additional data to prevent object reference issues - Added fallback for corrupted cache entries ## Performance & Reliability - All 69 console commands properly discovered and cached - 534 total discovery items successfully cached and restored - No more __PHP_Incomplete_Class cache corruption - Improved error handling and graceful fallbacks ## Testing & Quality - Fixed code style issues across discovery components - Enhanced logging for better debugging capabilities - Improved cache validation and error recovery Ready for production deployment with stable discovery system. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
82 lines
3.5 KiB
PHP
82 lines
3.5 KiB
PHP
#!/usr/bin/env php
|
|
<?php
|
|
declare(strict_types=1);
|
|
|
|
require_once __DIR__ . '/vendor/autoload.php';
|
|
|
|
use App\Framework\Core\AppBootstrapper;
|
|
use App\Framework\Performance\EnhancedPerformanceCollector;
|
|
use App\Framework\DateTime\SystemClock;
|
|
use App\Framework\DateTime\SystemHighResolutionClock;
|
|
use App\Framework\Performance\MemoryMonitor;
|
|
use App\Framework\Discovery\DiscoveryServiceBootstrapper;
|
|
use App\Framework\Console\ConsoleCommand;
|
|
|
|
// Create dependencies
|
|
$clock = new SystemClock();
|
|
$highResClock = new SystemHighResolutionClock();
|
|
$memoryMonitor = new MemoryMonitor();
|
|
$collector = new EnhancedPerformanceCollector($clock, $highResClock, $memoryMonitor, enabled: false);
|
|
$bootstrapper = new AppBootstrapper(__DIR__, $collector, $memoryMonitor);
|
|
|
|
try {
|
|
echo "Creating console app..." . PHP_EOL;
|
|
$consoleApp = $bootstrapper->bootstrapConsole();
|
|
|
|
echo "Getting container..." . PHP_EOL;
|
|
$reflection = new ReflectionClass($consoleApp);
|
|
$containerProperty = $reflection->getProperty('container');
|
|
$containerProperty->setAccessible(true);
|
|
$container = $containerProperty->getValue($consoleApp);
|
|
|
|
echo "Creating discovery bootstrapper..." . PHP_EOL;
|
|
$discoveryBootstrapper = new DiscoveryServiceBootstrapper($container, $clock);
|
|
|
|
echo "Running fresh discovery (forced, no cache)..." . PHP_EOL;
|
|
|
|
// Force a fresh discovery by calling performBootstrap directly
|
|
$reflectionBootstrapper = new ReflectionClass($discoveryBootstrapper);
|
|
$performBootstrapMethod = $reflectionBootstrapper->getMethod('performBootstrap');
|
|
$performBootstrapMethod->setAccessible(true);
|
|
|
|
$pathProvider = $container->get(\App\Framework\Core\PathProvider::class);
|
|
$cache = $container->get(\App\Framework\Cache\Cache::class);
|
|
|
|
echo "Calling performBootstrap..." . PHP_EOL;
|
|
$results = $performBootstrapMethod->invoke($discoveryBootstrapper, $pathProvider, $cache, null);
|
|
|
|
echo "Fresh discovery completed!" . PHP_EOL;
|
|
echo "Total attributes found: " . $results->attributes->count() . PHP_EOL;
|
|
|
|
$commands = $results->attributes->get(ConsoleCommand::class);
|
|
echo "ConsoleCommand attributes found: " . count($commands) . PHP_EOL;
|
|
|
|
if (count($commands) > 0) {
|
|
foreach ($commands as $discovered) {
|
|
$methodName = $discovered->methodName ? $discovered->methodName->toString() : '__invoke';
|
|
echo "- " . $discovered->className->getFullyQualified() . "::" . $methodName . PHP_EOL;
|
|
$command = $discovered->createAttributeInstance();
|
|
echo " Command: " . $command->name . " - " . $command->description . PHP_EOL;
|
|
}
|
|
} else {
|
|
echo "Still no ConsoleCommand attributes found!" . PHP_EOL;
|
|
|
|
// Let's check what classes are being discovered
|
|
$allTypes = $results->attributes->getAllTypes();
|
|
echo "All discovered attribute types: " . implode(', ', $allTypes) . PHP_EOL;
|
|
|
|
// Check scan paths
|
|
echo "Checking scan paths..." . PHP_EOL;
|
|
$sourcePath = $pathProvider->getSourcePath();
|
|
echo "Source path: $sourcePath" . PHP_EOL;
|
|
|
|
// Check if DemoCommand file exists in scan path
|
|
$demoCommandPath = $sourcePath . '/Framework/Console/DemoCommand.php';
|
|
echo "DemoCommand file exists: " . (file_exists($demoCommandPath) ? 'YES' : 'NO') . PHP_EOL;
|
|
echo "Full path: $demoCommandPath" . PHP_EOL;
|
|
}
|
|
|
|
} catch (Exception $e) {
|
|
echo "Error: " . $e->getMessage() . PHP_EOL;
|
|
echo "Stack trace: " . $e->getTraceAsString() . PHP_EOL;
|
|
} |