Skip to content

Commit e2b703b

Browse files
committed
Change Router to use redirect intercept exceptions
1 parent 0cd491c commit e2b703b

3 files changed

Lines changed: 5 additions & 3 deletions

File tree

system/CodeIgniter.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,8 @@ public function run(RouteCollectionInterface $routes = null, bool $returnRespons
252252
// If the route is a 'redirect' route, it throws
253253
// the exception with the $to as the message
254254
$this->response->redirect($e->getMessage(), 'auto', $e->getCode());
255+
$this->sendResponse();
256+
255257
$this->callExit(EXIT_SUCCESS);
256258
}
257259
catch (PageNotFoundException $e)

system/Router/Exceptions/RedirectException.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
class RedirectException extends \Exception
1010
{
11-
public static function forUnableToRedirect(string $route, string $code)
11+
public static function forRedirectIntercept(string $route)
1212
{
13-
return new static(lang('Redirect.forUnableToRedirect', [$route, $code]));
13+
return new static($route);
1414
}
1515
}

system/Router/Router.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ protected function checkRoutes(string $uri): bool
484484
// Is this route supposed to redirect to another?
485485
if ($this->collection->isRedirect($key))
486486
{
487-
throw RedirectException::forUnableToRedirect($val, $this->collection->getRedirectCode($key));
487+
throw RedirectException::forRedirectIntercept($val, $this->collection->getRedirectCode($key));
488488
}
489489

490490
$this->setRequest(explode('/', $val));

0 commit comments

Comments
 (0)