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

  • From: Fernando Gómez <fjgomez@xxxxxxxxx>
  • To: dokuwiki@xxxxxxxxxxxxx
  • Date: Thu, 26 Mar 2009 17:36:35 -0300

Hi,

Yesterday I posted a message in the plugin subforum [1], but following
chi's advice I'm bringing the issue to the list. For completeness I'll
paste here what I wrote on the forum.


I've found a strange behavior while developing a plugin. To test the
problem in an easily reproducible way, I've used the sample plugin
"now", from [2].

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 ;-)

[The day after, after discovering better debugging tools...]

Using Xdebug I've found that in file renderer.php, class
Doku_Renderer, the function plugin is called 7 times (with my plugin);
the caller is call_user_func_array in file parserutils.php. It is this
function plugin which in turn is calling the plugin's render method.

Is all this an expected behavior? Thanks in advance for your help.

Using DokuWiki 2009-02-14.



[1] http://forum.dokuwiki.org/thread/3543
[2] http://www.dokuwiki.org/devel:syntax_plugins#sample_plugin_1_-_now


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

Other related posts: