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... :-)
On 2 Mar 2005, at 13:50, Brion Vibber wrote:
ngungo wrote: [snip]
- I have to resister the hook in DefaultSettings.php with like this:
You should never edit DefaultSettings.php unless you're hacking up the main software itself; avoiding that is why we have extension hooks in the first place. Put customizations in LocalSettings.php.
function myFunction() { // Call function Article::updateArticle // (to post this statistics on a Special:TextStatistics page). return true; }
This function won't actually do anything, obviously, as it consists only of a comment and a true return. It won't even produce any evidence that it's being run unless you're stepping line by line in a debugger; how are you checking whether or not it's running successfully? What's the problem that you're posting about?
- Where do I write the above 'myFunction'? On what class? Article (or
editPage)?
In your own file, which you can include from LocalSettings.php. The purpose of hooks is to allow adding in some functions *without* changing the core code.
I tried putting this into my test REL1_4 installation's LocalSettings.php:
$wgHooks['ArticleSave'][] = 'myFunction'; // new function myFunction() { die("Testing!"); }
When I try to save, the script dies and prints "Testing!" as expected, showing clearly that the hook is run.
-- brion vibber (brion @ pobox.com) _______________________________________________ MediaWiki-l mailing list MediaWiki-l@Wikimedia.org http://mail.wikipedia.org/mailman/listinfo/mediawiki-l
:::: News is what powerful people don’t want you to hear; everything else is just publicity. -- Bill Moyers :::: Jan Steinman http://www.Bytesmiths.com/Van