From bd100c1f4fcbf57494045cb71241be0b154eb5bf Mon Sep 17 00:00:00 2001 From: onli Date: Tue, 27 May 2014 00:45:42 +0200 Subject: [PATCH] correct approach to detect installed plugins (#45) --- include/admin/plugins.inc.php | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/include/admin/plugins.inc.php b/include/admin/plugins.inc.php index ae9066ae..3abf3860 100644 --- a/include/admin/plugins.inc.php +++ b/include/admin/plugins.inc.php @@ -345,16 +345,22 @@ if (isset($_GET['serendipity']['plugin_to_conf'])) { 'install' => true); serendipity_plugin_api::hook_event('backend_plugins_fetchplugin', $fetchplugin_data); - // we now have to check that the plugin is not already installed or stackable to prevent invalid double instances - $existingPlugin =& serendipity_plugin_api::load_plugin($serendipity['GET']['install_plugin']); + // we now have to check that the plugin is not already installed, or stackable, to prevent invalid double instances $new_plugin = true; - if (is_object($existingPlugin)) { - $bag = new serendipity_property_bag(); - $existingPlugin->introspect($bag); - if ($bag->get('stackable') != true) { - $new_plugin = false; + foreach (serendipity_plugin_api::get_installed_plugins() as $pluginName) { + if ($serendipity['GET']['install_plugin'] === $pluginName) { + $existingPlugin =& serendipity_plugin_api::load_plugin($serendipity['GET']['install_plugin']); + if (is_object($existingPlugin)) { + $bag = new serendipity_property_bag(); + $existingPlugin->introspect($bag); + if ($bag->get('stackable') != true) { + $new_plugin = false; + } + } + break; } } + $data['new_plugin_failed'] = ! $new_plugin; if ($fetchplugin_data['install'] && $new_plugin) {