Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

redirect($namedRoute) missing helpful exception #1953

Closed
MGatner opened this issue Apr 18, 2019 · 1 comment
Closed

redirect($namedRoute) missing helpful exception #1953

MGatner opened this issue Apr 18, 2019 · 1 comment

Comments

@MGatner
Copy link
Member

MGatner commented Apr 18, 2019

Passing an invalid named route to redirect() causes a type error:

SYSTEMPATH/Router/RouteCollection.php at line 1117
ltrim() expects parameter 1 to be string, object given
...
1115                 // Lose any namespace slash at beginning of strings
1116                 // to ensure more consistent match.
1117                 $to     = ltrim($to, '\\');

This should be throwing something helpful, like HTTPException::forInvalidRedirectRoute. Tested with and without custom route definitions.

  • PHP: 7.2.16
  • CodeIgniter: 4.0.0-beta.2
@MGatner
Copy link
Member Author

MGatner commented Apr 18, 2019

It seems to be choking on Closures, trying to use ltrim() on them. Since this section is explicitly looking for a string match to $search I think it would be find to skip anything else:

foreach ($collection as $route)
{
	$from = key($route['route']);
	$to   = $route['route'][$from];
	if (! is_string($to))
	{
		 continue;
	}
...

MGatner added a commit to MGatner/CodeIgniter4 that referenced this issue Apr 21, 2019
@MGatner MGatner closed this as completed May 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant