Skip to content

fix: Load MX before instantiating the error mock controller - #562

Merged
hellopablo merged 1 commit into
developfrom
fix/errorhandler-mx-controller-early-bootstrap-develop
Sep 8, 2026
Merged

fix: Load MX before instantiating the error mock controller#562
hellopablo merged 1 commit into
developfrom
fix/errorhandler-mx-controller-early-bootstrap-develop

Conversation

@hellopablo

Copy link
Copy Markdown
Member

Same fix as #561 but targeting develop.

Early exceptions (before CodeIgniter's Router loads) can cascade into a second fatal when rendering the error view, because Nails\Common\Controller\Base extends MX_Controller and MX/Modules.php has not registered the MX_* autoloader yet.

Change

  • Require MX/Modules.php in ErrorHandler::instantiateMockController() when MX_Controller is not already loaded.
  • Wrap instantiateMockController() in try/catch (\Throwable) and fall back to halt().

Does not change URI filtering: production still halt()s disallowed characters as 404; non-prod still bubbles.

Error views can be rendered before the MX Router registers the MX_*
autoloader (e.g. URI character filtering). Nails\Common\Controller\Base
extends MX_Controller, so skip that load and error rendering fatals.
Fall back to halt() if the mock controller still cannot be created.
@hellopablo
hellopablo merged commit 03309d6 into develop Sep 8, 2026
4 checks passed
@hellopablo
hellopablo deleted the fix/errorhandler-mx-controller-early-bootstrap-develop branch September 8, 2026 06:51
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

Successfully merging this pull request may close these issues.

1 participant