Reputation: 389
I have a PHP scripts which displays lists of employees on my MediaWiki. I also have a special page, where you can administrate which users are employees, that works very well. However when you make a backend change on the special page, the change isn't displayed on the wikipage, where it's inserted with a tag, until after you edit that page, and change nothing, and save it.
It can only be because I'm using the wrong hook. I'm trying to use this hook instead, but it doesn't seem to be working: http://www.mediawiki.org/wiki/Manual:Hooks/ArticlePageDataBefore
Right now I'm using this hook. Just changing the variable name doesn't work:
$wgHooks['ParserFirstCallInit'][] = 'wfEmployeesParserInit';
// Hook our callback function into the parser
function wfEmployeesParserInit( Parser $parser ) {
// When the parser sees the <sample> tag, it executes
// the wfEmployeesRender function (see below)
$parser->setHook( 'employees', 'wfEmployeesRender' );
// Always return true from this function. The return value does not denote
// success or otherwise have meaning - it just must always be true.
return true;
}
// Execute
function wfEmployeesRender( $input, array $args, Parser $parser, PPFrame $frame ) {
...
Upvotes: 1
Views: 358
Reputation: 389
Thanks. I found a solution.
$wgHooks['ParserFirstCallInit'][] = 'wfNewsParserInit';
function wfNewsRender($input, array $args, Parser $parser, PPFrame $frame)
{
$parser->disableCache();
...
Upvotes: 1
Reputation: 9520
The hook isn't to blame here; rather it is MediaWiki's page caching -- pages are not updated unless they are edited or a periodic cache purge occurs. There are a few ways around this issue; you can do null edits; you can turn off caching; or you can purge the contents of the affected page(s), which force MW to re-render the page.
Some useful links with details of these methods:
How do I disable caching for pages using my extension?
How to prevent MW from caching pages
Upvotes: 1