[Pushed] Plugins can't return *empty* values to hooks.
In https://github.com/mybb/mybb/blob/mybb_1...s.php#L145 , the returned value is checked just using if:

That means
    "" (an empty string)
    0 (0 as an integer)
    0.0 (0 as a float)
    "0" (0 as a string)
    array() (an empty array)

can't be returned by plugins and that's too restrictive.

IMO we should check the returned value using isset() so that only NULL is excluded.

There *might* be issues when multiple plugins hook to a same hook if we make changes here, though I'm not sure. But I think it's worth removing the restrict.


If a hooked function is called via the variable function https://github.com/mybb/mybb/blob/mybb_1...s.php#L142 , the returned value is what the hooked function returns.
But if a hooked function is called via call_user_func_array() https://github.com/mybb/mybb/blob/mybb_1...s.php#L136 , if the returned value is FALSE, it might also be that call_user_func_array() is having errors on the hooked function. Ref https://www.php.net/manual/en/function.c...-array.php .

I don't quite understand using call_user_func_array() over call_user_func() here. The latter one only returns what the callback returns. Ref https://www.php.net/manual/en/function.c...r-func.php .
Could be wrong but worth a try.
Email me at: [email protected]

Messages In This Thread
Plugins can't return *empty* values to hooks. - by noyle - 2020-10-26, 08:33 AM

Forum Jump:

Users browsing this thread: 1 Guest(s)