Last modified: 2013-06-25 21:24:49 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T52134, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 50134 - Hook functions should not be required to return a value
Hook functions should not be required to return a value
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
General/Unknown (Other open bugs)
1.22.0
All All
: Normal normal (vote)
: ---
Assigned To: Ori Livneh
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-06-24 21:41 UTC by Ori Livneh
Modified: 2013-06-25 21:24 UTC (History)
8 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Ori Livneh 2013-06-24 21:41:13 UTC
When a hook neglects to return a value, Hooks::run throws an MWException with the message "Detected bug in an extension! Hook $func failed to return a value; should return true to continue hook processing or false to abort."

This is a frustrating gotcha that has caused us some serious in the past (see bug 49727 for a recent example). Most hook handlers are written with the intent of complementing or augmenting core functionality rather than vetoing it, making it quite natural for a developer to forget that the caller is waiting for permission to proceed. The potential for confusion is magnified by the fact that DOM event handlers and jQuery event handlers are not required to return an explicit value for the handled event to continue propagating.

We should tolerate implicit and explicit null return values from hook handlers. Making this change should not break anything, as any hook handler currently returning null is treated as an error.
Comment 1 Gerrit Notification Bot 2013-06-24 21:45:48 UTC
Related URL: https://gerrit.wikimedia.org/r/70328 (Gerrit Change I11deb2117ff9233c77868470f50e0d8f74053545)
Comment 2 Jack Phoenix 2013-06-24 21:59:44 UTC
It should be noted that this originally was an intentional change, committed by Brion in r23133 (see http://www.mediawiki.org/wiki/Special:Code/MediaWiki/23133) on 20 June 2007.
Comment 3 Ori Livneh 2013-06-25 21:24:49 UTC
Jack, thanks very much for tracking that down.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links