Interesting enough, this trick does not prevent the problem of the callback running
twice on save. If I put as the first lines of the callback:
static $hasRun = false;
if ($hasRun) {
error_log("already ran");
return '';
}
$hasRun = true;
error_log('first time');
and put my tag on a page and save it, I get two "first time" messages in the
error log.
DanB
-----Original Message-----
From: mediawiki-l-bounces(a)lists.wikimedia.org
[mailto:mediawiki-l-bounces@lists.wikimedia.org] On Behalf Of Nathan Larson
Sent: Thursday, December 05, 2013 2:51 PM
To: MediaWiki announcements and site admin list
Subject: Re: [MediaWiki-l] Preventing a tag extension from rendering twice on save?
On Thu, Dec 5, 2013 at 2:32 PM, Daniel Barrett <danb(a)vistaprint.com> wrote:
I've noticed that parser tag extensions render
twice when an article
is saved from the edit page.
All I did was write a parser tag <foo> that runs error_log('foo').
It prints once when I hit <foo/> on a page, but twice when saving the
page from the wiki editor.
Is there a way to prevent this double-running on save?
Even way for the extension itself to detect it's on the first (or
second) run and suppress itself?
I have an extension that is heavyweight, making a SQL query to an
external database, and I don't want to run twice.
Thanks for any insights!
DanB
_______________________________________________
MediaWiki-l mailing list
MediaWiki-l(a)lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-l