Fixed Error report handler initialized before required libraries loaded

Affected version

Lukas W.

Formerly katsulynx
There's an edge case in the core startup system that sets the error report handlers at a point where the required libraries for them to actually be executed aren't loaded yet (specifically between lines 70 and 71 in src/XF.php. If an error happens anywhere after that point before initializing the autoloader, the following error masks the actual error, making debugging pretty nasty:

[B]Fatal error[/B]: Uncaught Error: Call to undefined function XF\utf8_substr() in /var/www/forum/src/XF/Error.php:137 Stack trace: #0 /var/www/forum/src/XF/App.php(2189): XF\Error->logException(Object(Error), true, '') #1 /var/www/forum/src/XF.php(170): XF\App->logException(Object(Error), true) #2 [internal function]: XF::handleException(Object(Error)) #3 {main} thrown in [B]/var/www/forum/src/XF/Error.php[/B] on line [B]137[/B]
  • Wow
Reactions: Xon

XF Bug Bot

XenForo bug fixer bot
Staff member
Thank you for reporting this issue. It has now been resolved and we are aiming to include it in a future XF release (2.1.5).

Change log:
Move setting up XenForo's error handling to be part of startSystem rather than standardizeEnvironment to ensure that the necessary classes/functions are available before they may be called.
Any changes made as a result of this issue being resolved may not be rolled out here until later.