Add CategoryAfterPageAdded / CategoryAfterPageRemoved hooks
authorOri Livneh <ori@wikimedia.org>
Tue, 5 Mar 2013 22:43:03 +0000 (14:43 -0800)
committerGerrit Code Review <gerrit@wikimedia.org>
Wed, 6 Mar 2013 04:01:54 +0000 (04:01 +0000)
commita4afffd2ba2f19413712e6165b3f5585907e879b
tree01d1f24099f009c24cfa2a766b2bfffca957688d
parent3933910d7241e6561c502f1acd96456b86a6b1da
Add CategoryAfterPageAdded / CategoryAfterPageRemoved hooks

My first instinct was to derive the hook signature from the implementation and
have a generic 'PageCategoriesUpdated' hook that receives the WikiPage object
and two arrays ($added, $deleted). After some reflection I decided to iterate
through each array and call the hook once per category. I like this way of
doing things because a change in page membership could be thought of from two
directions: it is either the category that is gaining or losing a member, or
the page that is gaining or losing a category.

The category name is sufficient for instantiating a Category object without
additional queries being needed, so my preference was to pass objects rather
than string identifiers.

If implementors of handlers happen to be interested in the set of categories or
pages being updated, it is still the case that they only need to write one
function, and track state using a class property.

Change-Id: Ica4c5fb3acdea6c00678ec0794808fa50a1dd39a
RELEASE-NOTES-1.21
docs/hooks.txt
includes/WikiPage.php