Skip to content

Commit cafaf4c

Browse files
committed
fix: handle the error 404 when get_instance() function is not available
Signed-off-by: otengkwame <developerkwame@gmail.com>
1 parent 9269ce9 commit cafaf4c

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

Core/core/Base_Exceptions.php

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,16 @@ public function __construct()
4444
private function redirectTo404Handler($router): void
4545
{
4646
$missingRoute = ucfirst($router->class) . '/' . $router->method;
47-
$redirectUrl = sprintf(
48-
'%s%s?url=%s',
49-
$router->config->config['base_url'],
50-
$router->routes['404_override'],
51-
urlencode($missingRoute)
52-
);
53-
54-
header('Location: ' . $redirectUrl, true, 302);
47+
48+
// $redirectUrl = sprintf(
49+
// '%s%s?url=%s',
50+
// $router->config->config['base_url'],
51+
// $router->routes['404_override'],
52+
// urldecode($missingRoute)
53+
// );
54+
55+
$handleError404Url = $router->config->config['base_url'] . $router->routes['route_not_found'];
56+
header('Location: ' . $handleError404Url, true, 302);
5557
exit;
5658
}
5759

@@ -99,7 +101,7 @@ public function show_error($heading, $message, $template = 'error_general', $sta
99101

100102
$RTR = $GLOBALS['RTR'];
101103

102-
if ($status_code == 404) {
104+
if (!function_exists('get_instance')) {
103105
$this->redirectTo404Handler($RTR);
104106
}
105107

0 commit comments

Comments
 (0)