[dokuwiki] Re: Plugins: Multiple executions of the render method in syntax.php

  • From: Christopher Smith <chris@xxxxxxxxxxxxx>
  • To: dokuwiki@xxxxxxxxxxxxx
  • Date: Thu, 26 Mar 2009 23:27:45 +0000


On 26 Mar 2009, at 20:36, Fernando Gómez wrote:


Adding these lines within the plugin's render function,

     // debug: how many times is this function running?
     $fp = fopen('/tmp/dokuwiki-plugin-now.log', 'a');
     fwrite($fp, date("H:i:s") . " -- syntax-render\n");
     fclose($fp);

I've found that each time I visit a page that uses "[NOW]", at least
*two* entries are added to the log. BTW, the syntax that is firing the
plugin (in the example, the string "[NOW]") is occuring only once in
the page.

But that's not all: With the plugin I'm developing, I've seen up to
*seven* runs of render for each single page visit! Since my plugin's
render function fetches content from another server, you may
understand why I'd prefer that it runs only once ;-)


There is insufficient information here to provide a definitive answer.

Is your debug code within a conditional block based on the $mode value?
If not, add $mode to your output line.

What is the entire content of the page - the raw wiki text?
Do you have anything in place likely to prevent caching?
What template and plugins are you using?

In your examination of the xdebug profile you haven't come out far enough. You need to look at how many times the renderer is being run and from where.

Under normal circumstances, using the default template and with caching operating properly, I would expect dokuwiki to execute your code block twice (once for metadata and once for xhtml) or not at all (xhtml & metadata output retrieved from cache). If caching is disabled, first heading enabled and a template which provides links in another block (e.g. sidebar) is in use, your code could end up being executed lots of times.

- Chris

--
DokuWiki mailing list - more info at
http://wiki.splitbrain.org/wiki:mailinglist

Other related posts: