-
Notifications
You must be signed in to change notification settings - Fork 11.7k
Closed
Description
If undefined action passed In UrlGenerator::action(), it's throw fatal exception
Call to a member function domain() on a non-object
with fully uninformative debug stack
because route, which was returned by $this->routes->getByAction($action) is not checked, before it passes to $this->toRoute(... and can be null instead of Route
// current version
public function action($action, $parameters = array(), $absolute = true)
{
if ($this->rootNamespace && ! (strpos($action, '\\') === 0))
{
$action = $this->rootNamespace.'\\'.$action;
}
else
{
$action = trim($action, '\\');
}
return $this->toRoute($this->routes->getByAction($action), $parameters, $absolute);
}so, it seems logical to add some check, as in UrlGenerator::route()
public function action($action, $parameters = array(), $absolute = true)
{
if ($this->rootNamespace && ! (strpos($action, '\\') === 0))
{
$action = $this->rootNamespace.'\\'.$action;
}
else
{
$action = trim($action, '\\');
}
if ( !is_null($route = $this->routes->getByAction($action)))
{
return $this->toRoute($route, $parameters, $absolute);
}
throw new InvalidArgumentException("Action {$action} not defined.");
}Metadata
Metadata
Assignees
Labels
No labels