Gergő Tisza has uploaded a new change for review.
https://gerrit.wikimedia.org/r/275708
Change subject: Update documentation of hook return values
......................................................................
Update documentation of hook return values
Current convention seems to be to omit explicit "return true;" on
successful hook execution, so let's have the docs say that.
Change-Id: If9e294813cf4acfa6df45e0edb70f5de7f092faa
---
M docs/hooks.txt
1 file changed, 8 insertions(+), 3 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/08/275708/1
diff --git a/docs/hooks.txt b/docs/hooks.txt
index 8955f54..bec9a5e 100644
--- a/docs/hooks.txt
+++ b/docs/hooks.txt
@@ -178,11 +178,12 @@
Hooks can return three possible values:
- * true: the hook has operated successfully
+ * no value ("return null;" or just "return;" or no explicit return
+ statement at all): the hook has operated successfully
* "some string": an error occurred; processing should stop and the error
- should be shown to the user
+ should be shown to the user
* false: the hook has successfully done the work necessary and the calling
- function should skip
+ function should skip
The last result would be for cases where the hook function replaces the main
functionality. For example, if you wanted to authenticate users to a custom
@@ -198,6 +199,10 @@
Returning false makes less sense for events where the action is complete, and
will normally be ignored.
+In older versions of MediaWiki, hooks were required to return true on success.
+This is deprecated but still works (has the same result as not returning any
+value).
+
Note that none of the examples made use of create_function() as a way to
attach a function to a hook. This is known to cause problems (notably with
Special:Version), and should be avoided when at all possible.
--
To view, visit https://gerrit.wikimedia.org/r/275708
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: If9e294813cf4acfa6df45e0edb70f5de7f092faa
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Gergő Tisza <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits