At 3/2/2005 11:03 PM, Jan Steinman wrote:
By making a dummy function that returns true, I think
ngungo
misunderstands the use of hooks.
To paraphrase Brion (correct me if I'm wrong), hook functions must have
side-effects if they are to be useful. Their return value is discarded.
For example, an ArticleSave hook might determine if an article had certain
dynamic content tags, and then mark the article in such a way that it
would not be cached in the future. (To tie two threads together... :-)
I did not know that, thanks for the tip :)
I grepped for wgHook in 1.3.10, and could not find it. Is it in 1.4 only ?
Let me download that... Oh I see, 1.4 indeed. So you guys added the
command-event/observer design pattern, that's neat.
Is is still time to request specific events for 1.4 ? I'm trying to force a
specific skin to be used for specific pages (I know it's evil, but trust me
on this one). No way to do it with the current extension mechanism. I
assume it's in OutputPage::output(), around $sk = $wgUser->getSkin(); ?
Could you eventually add a hook at the beginning and end of
OutputPage::output() ?
We have implemented command/observer (i.e. event/hooks) in our C++ products
a while back, and here is my 2 cents about it: it's pretty powerful, but
people who are not directly involved in the main source code had
difficulties finding them, since they are typically spread all around the
code. External developers would not know what could be done, what could be
"observed", who would invoke events, who would listen to them, etc. I would
just suggest you make sure your documentation (i.e. hooks.doc) is
up-to-date and in-sync. A long time ago I wrote a script to do that
automatically on a nightly basis, i.e. create a specific page documenting
who invokes events (and where), and (optionally) who listens to them (i.e.
who installs hooks, it helps).
This is actually even more important because of the way you implemented the
pattern: it seems the event/hook signature is not "frozen": each event/hook
can have a different number of arguments attached to it. So unless I'm
wrong, any change made to an event/hook signature in the MediaWiki code
will break people's hooks. In C++, we "avoided" that problem by passing a
void* (that you would cast to whatever, int*, float*, object*, etc).
--
Sebastien Barre