Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion src/Common/Service/ErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,16 @@ public static function renderErrorView(
);
}

static::instantiateMockController();
try {
static::instantiateMockController();
} catch (\Throwable $e) {
static::halt(
ArrayHelper::get('sMessage', $aData) ?: $e->getMessage(),
ArrayHelper::get('sSubject', $aData),
$iCode,
$aTrace
);
}

// Flush the output buffer
if ($bFlushBuffer) {
Expand Down Expand Up @@ -670,6 +679,14 @@ protected static function instantiateMockController()

require_once BASEPATH . 'core/Controller.php';

// URI filtering (and other early failures) can occur before the MX
// Router is loaded. Nails\Common\Controller\Base extends MX_Controller,
// so the mock controller used to render error views must ensure MX is
// available. Modules.php registers the MX_* autoloader.
if (!class_exists('MX_Controller', false)) {
require_once Config::get('NAILS_COMMON_PATH') . 'MX/Modules.php';
}

// Match pocketarc/codeigniter system/core/CodeIgniter.php:
// Security requires $charset; Input requires the Security instance.
$sCharset = strtoupper((string) config_item('charset'));
Expand Down
Loading