[1.x] Conditional
extender instantiates the extenders array even when the conditional is false
#3897
Labels
Conditional
extender instantiates the extenders array even when the conditional is false
#3897
Current Behavior
The
Conditional
extender instantiates provided extenders even if the associated condition isfalse
. This can lead to unintended side effects, especially if the constructors of these extenders perform actions. More critically, if the extender class doesn't even exist, it will result in a fatal error due to class not being found, regardless of the condition's value.Steps to Reproduce
Reference a nonexistent extender class within the Conditional extender.
Upon execution, PHP will throw a fatal error stating that the
NonexistentExtender
class was not found, even though the condition was set to false.Expected Behavior
The expected behavior is that the
Conditional
extender should only attempt to instantiate and use provided extenders when the associated condition evaluates totrue
, and should completely ignore them when the condition isfalse
.Screenshots
No response
Environment
Output of
php flarum info
Possible Solution
Instead of directly providing an array of extenders, wrap them in a callback, ie invokable class
Additional Context
No response
The text was updated successfully, but these errors were encountered: