Not sure if this is a bug or desired behavior, but nonetheless it isn't documented.
1) I added the following code to the switch statement in render():
$renderer->doc .= $this->_renderXhtml($data,$renderer);
msg("######## CALL TIME: ".xdebug_time_index());
On the screen, after saving a page, I get 1 'message', meaning that render('xhtml') is called only 1 time.
However, when I do the same for case: 'metadata', I can see the function is called twice at 2 different times. This can cause problems and performance issues when performance intensive tasks are called when metadata is being rendered. In short, it is inefficient and should be documented if it is not a bug.
From the mailing list discussion (http://www.freelists.org/post/dokuwiki/plugin-render-called-multiple-times-for-metadata):
I now think I know why the two calls are made after saving and before displaying the changed page(*)
- metadata is kept in step with xhtml, so fresh xhtml means fresh metadata. This will be triggered after page editing as well as on other occasions.
- a new changelog entry (part of page editing process) requests metadata be re-rendered.
Ben (Coburn), Andi, do you know if/why re-rendering is required here.
(*) I don't reckon these are on the same "run". changelog is part of the save process and done on the "POST". xhtml rendering is done as part of show (normal page viewing) and done on a "GET". save forwards to show.