Fixed Controller::errorException ergonomics

Xon

Well-known member
Affected version
2.2.12
If code (incorrectly) does this:
Code:
throw $this->errorException($this->noPermission())
errorException has no type hints to indicate It's type signature is actually string|string[]|Stringable|Stringable[], so passing it the result of noPermission doesn't cause any errors or hints that it has the wrong type.

Instead the XF error page will throw "Object of class XF\Mvc\Reply\View could not be converted to string", converting what was a user facing error message into a hard error, while obscure the original message

Ideally XF\Mvc\Reply\Reply\Error or somewhere in the callchain of errorException should validate the array elements (or singular item) is a string, or something which has a _toString method. Sadly a direct type hint on Stringable is php 8+ only.
 
Thank you for reporting this issue, it has now been resolved. We are aiming to include any changes that have been made in a future XF release (2.2.13).

Change log:
Perform validation on error reply values
There may be a delay before changes are rolled out to the XenForo Community.
 
Top Bottom