[dokuwiki] plugin render() called multiple times for metadata?

Hello everyone. This is my first time posting here.

I was attempting to write a plugin similar to the 'data' plugin that uses
mysql for a project I am working on, but I ran into the following situation:

1) I added the following code to the switch statement in render():
[requires xdebug]
case 'xhtml':
  $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 is undesirable because I have
multiple attempts at inserting data into the database.

1. Should my _saveToDb() function be called from render(), or am I doing
this wrong? Any other suggestions on where the best place to save the
metadata to a database is? Why is the metadata rendered twice?

...

Thank you

Other related posts: