Skip to content

Commit

Permalink
bug #6476 ControllerResolver::getController return value check (fracsi)
Browse files Browse the repository at this point in the history
This PR was squashed before being merged into the 4.x branch.

Discussion
----------

ControllerResolver::getController return value check

ControllerResolver::getController throws InvalidArgumentException resulting in 500 error, when the `crudControllerFqcn` or `crudAction` query param is changed by hand (non-existent CrudController).

Commits
-------

7cc04d0 ControllerResolver::getController return value check
  • Loading branch information
javiereguiluz committed Oct 16, 2024
2 parents 072b023 + 7cc04d0 commit 659566c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Factory/ControllerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,11 @@ private function getController(string $controllerInterface, ?string $controllerF
}

$newRequest = $request->duplicate(null, null, ['_controller' => [$controllerFqcn, $controllerAction]]);
$controllerCallable = $this->controllerResolver->getController($newRequest);
try {
$controllerCallable = $this->controllerResolver->getController($newRequest);
} catch (\InvalidArgumentException $e) {
$controllerCallable = false;
}

if (false === $controllerCallable) {
throw new NotFoundHttpException(sprintf('Unable to find the controller "%s::%s".', $controllerFqcn, $controllerAction));
Expand Down

0 comments on commit 659566c

Please sign in to comment.