Skip to content
Snippets Groups Projects
Commit e842bd07 authored by Chris Smith's avatar Chris Smith
Browse files

Fix for FS#1598 - allow a plugin to be a singleton if it so desires

DokuWiki typically instantiates a plugin once and reuses
that instance whenever the plugin is required. However on
some occasions DokuWiki will request a new instantiation of
a plugin.  This particularly applies to render plugins.  This
patch allows a plugin to force DokuWiki to reuse the existing
instance.

If a plugin wishes to only be instantiated once then it
should implement an "isSingleton()" method and that
method should return boolean true.

darcs-hash:20090211143520-f07c6-5c1a33dbed55f0b196a204745fe3139f3c7c0aa9.gz
parent 0e115661
No related branches found
No related tags found
No related merge requests found
......@@ -215,6 +215,15 @@ class DokuWiki_Plugin {
return p_render($format, p_get_instructions($text),$info);
}
/**
* Allow the plugin to prevent DokuWiki creating a second instance of itself
*
* @return bool true if the plugin can not be instantiated more than once
*/
function isSingleton() {
return false;
}
// deprecated functions
function plugin_localFN($id) { return $this->localFN($id); }
function plugin_locale_xhtml($id) { return $this->locale_xhtml($id); }
......
......@@ -66,7 +66,7 @@ class Doku_Plugin_Controller {
//plugin already loaded?
if(!empty($DOKU_PLUGINS[$type][$name])){
if ($new) {
if ($new && !$DOKU_PLUGINS[$type][$name]->isSingleton()) {
$class = $type.'_plugin_'.$name;
return class_exists($class) ? new $class : null;
} else {
......
......@@ -266,5 +266,13 @@ class DokuWiki_Syntax_Plugin extends Doku_Parser_Mode {
return $conf;
}
/**
* Allow the plugin to prevent DokuWiki creating a second instance of itself
*
* @return bool true if the plugin can not be instantiated more than once
*/
function isSingleton() {
return false;
}
}
//Setup VIM: ex: et ts=4 enc=utf-8 :
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment