Page MenuHomePhabricator

Functions are always called with a null parameter, even if empty
Closed, ResolvedPublic


In AbuseFilterParser we have several functions which only take one argument, and for which we're using the "notenoughargs" exception. However, since we have the "noparams" exception, which is more specifical, I decided to go and use the latter where possible (adding another parameter to the message for specifying the amount of needed parameters). I thought it would have been a straightforward patch, but with huge surprise I found out the following:

  1. Go to whatever page lets you test filter syntax (e.g. /tools)
  2. Write down something like lcase()
  3. Check syntax...

No error is displayed! It took me no time to find out the reason: $args is never empty, instead it always has a null element (where "null" is the AFPData's null). This means that functions get called with "supplied parameters + 1" arguments, thus never triggering such exception. They still work, since they do their work on NULL, but this shouldn't happen: if the user wants to execute a function on NULL, he'd just call it with an explicit null, otherwise leaving parameters empty must be treated as 0 parameters provided.

Event Timeline

Change 442276 had a related patch set uploaded (by Daimona Eaytoy; owner: Daimona Eaytoy):
[mediawiki/extensions/AbuseFilter@master] Use noparams exception and correctly count function parameters

Change 442276 merged by jenkins-bot:
[mediawiki/extensions/AbuseFilter@master] Use noparams exception and correctly count function parameters