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
This commit is contained in:
2025-09-12 20:05:18 +02:00
parent 8040d3e7a5
commit e30753ba0e
46990 changed files with 10789682 additions and 89639 deletions

View File

@@ -56,9 +56,13 @@ final readonly class ApiVersioningMiddleware implements HttpMiddleware
$context = $next($context);
// Add version headers to response
$response = $this->addVersionHeaders($context->response, $requestedVersion);
if ($context->response instanceof HttpResponse) {
$response = $this->addVersionHeaders($context->response, $requestedVersion);
return $context->withResponse($response);
return $context->withResponse($response);
}
return $context;
}
public function validateRouteVersion(ApiVersionAttribute $versionAttribute, ApiVersion $requestedVersion): bool
@@ -124,7 +128,7 @@ final readonly class ApiVersioningMiddleware implements HttpMiddleware
'Content-Type' => 'application/json',
'API-Version' => $this->config->getLatestVersion()->toString(),
]),
body: $this->jsonSerializer->serialize($error)
body: $this->jsonSerializer->serialize($error) ?: '{"error":"Serialization failed"}'
);
}
}

View File

@@ -14,6 +14,7 @@ use App\Framework\Http\MiddlewareContext;
use App\Framework\Http\MiddlewarePriority;
use App\Framework\Http\MiddlewarePriorityAttribute;
use App\Framework\Http\Next;
use App\Framework\Http\Request;
use App\Framework\Http\RequestStateManager;
use App\Framework\Http\StateKey;
use App\Framework\Meta\MetaData;
@@ -25,6 +26,7 @@ use App\Framework\Router\Result\ContentNegotiationResult;
use App\Framework\Router\Result\JsonResult;
use App\Framework\Router\Result\Redirect;
use App\Framework\Router\Result\ViewResult;
use App\Framework\Router\RouteContext;
use App\Framework\Router\RouteDispatcher;
use App\Framework\Router\Router;
@@ -64,6 +66,7 @@ final readonly class RoutingMiddleware implements HttpMiddleware
try {
// Measure route matching
/** @var RouteContext $routeContext */
$routeContext = $this->performanceService->measure(
'route_matching',
fn () => $this->router->match($request),
@@ -150,7 +153,7 @@ final readonly class RoutingMiddleware implements HttpMiddleware
/**
* Perform IP and namespace-based authentication checks
*/
private function performAuthenticationChecks($request, $routeContext): void
private function performAuthenticationChecks(Request $request, RouteContext $routeContext): void
{
$clientIp = $this->getClientIp($request);
$controllerClass = $routeContext->match->route->controller;
@@ -182,7 +185,7 @@ final readonly class RoutingMiddleware implements HttpMiddleware
/**
* Get client IP address
*/
private function getClientIp($request): IpAddress
private function getClientIp(Request $request): IpAddress
{
return $request->server->getClientIp() ?? IpAddress::localhost();
}