Skip to content

Commit 05b6573

Browse files
committed
🐛 fix session() and get_instance() methods not found when using plates templating
Signed-off-by: otengkwame <[email protected]>
1 parent 5784c34 commit 05b6573

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

Core/core/Base_Exceptions.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,11 @@ public function show_exception($exception)
108108
show_404();
109109
}
110110

111-
$location = str_replace('../', '', get_instance()->router->directory);
111+
$directory = (get_instance()) ? get_instance()->router->directory : '';
112+
113+
$location = str_replace('../', '', $directory);
112114

113-
$filepath = session('__view_path') ?: $exception->getFile();
115+
$filepath = function_exists('session') ? session('__view_path') : $exception->getFile();
114116
$line = $exception->getLine();
115117
$message = $exception->getMessage();
116118
$num = $exception->getCode();
@@ -173,15 +175,18 @@ public function show_php_error($severity, $message, $filepath, $line)
173175
if (empty($templates_path)) {
174176
$templates_path = VIEWPATH . 'errors' . DIRECTORY_SEPARATOR;
175177
}
178+
179+
$directory = (get_instance()) ? get_instance()->router->directory : '';
176180

177-
$location = str_replace('../', '', get_instance()->router->directory);
181+
$location = str_replace('../', '', $directory);
182+
178183
$filelocation = $filepath;
179184
$severity = isset($this->levels[$severity]) ? $this->levels[$severity] : $severity;
180185

181186
if (_evaluated($filepath)) {
182187

183188
$evaluated = true;
184-
$file = session('__view_path');
189+
$file = function_exists('session') ? session('__view_path') : '';
185190
$_error =& load_class('Exceptions', 'core');
186191
$_error->log_exception($severity, $message, $file, $line);
187192

0 commit comments

Comments
 (0)