-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Jim Wilson wrote:
Per r23133, any function that is called by a hook and does not return a value will through a full stop error.
Since not returning anything in PHP is equivalent (more or less) to returning null, is there any concern that the extension writer's intent was to do so? Or is this simply a massive case of forgotten "return true" statements?
A hook function (and I mean specifically those run via wfRunHooks()) can return three possible values:
true - continue running hooks, and return 'true' from wfRunHooks() false - cancel all remaining hooks, and return 'false' from wfRunHooks() a string - display the string as an error message, and return 'false' from wfRunHooks()
NULL is not a valid return value, but it's not a string and it evaluates to false when checked in boolean context. Since true is what is intended 99% of the time, the NULL default return breaks things.
There's three ways to handle that: 1) Ignore it -- what we did before ;) 2) Toss a big error message so it's obvious it needs to be fixed -- what I just added to try it out 3) Change it to treat as if you returned true instead of false -- what Tim suggests as the most convenient behavior
My one concern about 3) is that it may encourage continuing breakage in extensions that try to run across multiple versions, since they'd have to remember to return true for older versions.
- -- brion vibber (brion @ wikimedia.org)