Skip to content
Snippets Groups Projects
Commit f6ec8df8 authored by Adrian Lang's avatar Adrian Lang
Browse files

Allow plugins to specify that they have to be instantiated

Plugins may return false in isSingleton to let plugin_load return a new
instance every time it is called.
Renderer plugins are not loaded with $new set to true, but instead specify
themself that they are not singletons. This behaviour allows the odt renderer
to keep working (see #1598).
parent ea6dfbca
No related branches found
No related tags found
No related merge requests found
......@@ -49,6 +49,15 @@ class Doku_Renderer extends DokuWiki_Plugin {
trigger_error('getFormat() not implemented in '.get_class($this), E_USER_WARNING);
}
/**
* Allow the plugin to prevent DokuWiki from reusing an instance
*
* @return bool false if the plugin has to be instantiated
*/
function isSingleton() {
return false;
}
//handle plugin rendering
function plugin($name,$data){
......
......@@ -585,7 +585,7 @@ function & p_get_renderer($mode) {
// Maybe a plugin/component is available?
list($plugin, $component) = $plugin_controller->_splitName($rname);
if (!$plugin_controller->isdisabled($plugin)){
$Renderer =& $plugin_controller->load('renderer',$rname, true);
$Renderer =& $plugin_controller->load('renderer',$rname);
}
if(is_null($Renderer)){
......
......@@ -231,12 +231,12 @@ class DokuWiki_Plugin {
}
/**
* Allow the plugin to prevent DokuWiki creating a second instance of itself
* Allow the plugin to prevent DokuWiki from reusing an instance
*
* @return bool true if the plugin can not be instantiated more than once
* @return bool false if the plugin has to be instantiated
*/
function isSingleton() {
return false;
return true;
}
// deprecated functions
......
......@@ -66,7 +66,7 @@ class Doku_Plugin_Controller {
//plugin already loaded?
if(!empty($DOKU_PLUGINS[$type][$name])){
if ($new && !$DOKU_PLUGINS[$type][$name]->isSingleton()) {
if ($new || !$DOKU_PLUGINS[$type][$name]->isSingleton()) {
$class = $type.'_plugin_'.$name;
return class_exists($class) ? new $class : null;
} else {
......
......@@ -266,13 +266,5 @@ 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