[Mediawiki-l] ArticleSave hook
ngungo
ngungo at 56degrees.com
Wed Mar 2 22:58:47 UTC 2005
I got it now. Thanks everyone.
I can sleep tonight!!!
ngungo
-----Original Message-----
From: mediawiki-l-bounces at Wikimedia.org
[mailto:mediawiki-l-bounces at Wikimedia.org] On Behalf Of Brion Vibber
Sent: Wednesday, March 02, 2005 3:50 PM
To: MediaWiki announcements and site admin list
Subject: Re: [Mediawiki-l] ArticleSave hook
ngungo wrote:
[snip]
> 2. 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?
> 4. 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)
More information about the MediaWiki-l
mailing list