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


That means
    "" (an empty string)
    0 (0 as an integer)
    0.0 (0 as a float)
    "0" (0 as a string)
    NULL
    FALSE
    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.

Edited:

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.
Reply
#2
I agree that isset should be used instead.
Reply
#3
I think this is worth changing.
Reply
#4
Hi,

Thank you for your report. We have pushed this issue to our Github repository for further analysis where you can track our commits and progress with fixing this bug. Discussions regarding this bug may also take place there too.

Follow this link to visit the issue on Github: https://github.com/mybb/mybb/issues/4230

Thanks for contributing to MyBB!

Regards,
The MyBB Group
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)