From 74efffc3dc025c612dcdfa70f31ad24dccf36682 Mon Sep 17 00:00:00 2001
From: Andreas Gohr <andi@splitbrain.org>
Date: Sat, 19 Mar 2011 14:16:50 +0100
Subject: [PATCH] warn about wrongly installed plugin

When a plugin is installed in the wrong directory, the class loading
will fail. This patch tries to find the correct directory from the
plugin.info.txt (using the base key) and give a hint to the user on how
to fix this.
---
 inc/plugincontroller.class.php | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/inc/plugincontroller.class.php b/inc/plugincontroller.class.php
index 6e361e172..cec5c73a9 100644
--- a/inc/plugincontroller.class.php
+++ b/inc/plugincontroller.class.php
@@ -96,7 +96,15 @@ class Doku_Plugin_Controller {
 
         //construct class and instantiate
         $class = $type.'_plugin_'.$name;
-        if (!class_exists($class)) return null;
+        if (!class_exists($class)){
+            # the plugin might be in the wrong directory
+            $inf = confToHash(DOKU_PLUGIN."$dir/plugin.info.txt");
+            if($inf['base'] && $inf['base'] != $plugin){
+                msg("Plugin installed incorrectly. Rename plugin directory '".
+                    hsc($plugin)."' to '".hsc($inf['base'])."'.",-1);
+            }
+            return null;
+        }
 
         $DOKU_PLUGINS[$type][$name] = new $class;
         return $DOKU_PLUGINS[$type][$name];
-- 
GitLab