]> git.mjollnir.org Git - s9y.git/commitdiff
fix some evil error that cause x additional SQL query per page per plugin.
authorgarvinhicking <garvinhicking>
Thu, 19 May 2005 14:39:21 +0000 (14:39 +0000)
committergarvinhicking <garvinhicking>
Thu, 19 May 2005 14:39:21 +0000 (14:39 +0000)
That sucks, we'll need to release 0.8.2 soon then.

docs/NEWS
include/plugin_api.inc.php

index 1a0e5fbb78ff8543cbb8fcf64d5626203bac8015..324bb0ab397c682de0271dd8ea49313d08c5ffc5 100644 (file)
--- a/docs/NEWS
+++ b/docs/NEWS
@@ -43,6 +43,9 @@ Version 0.9 ()
 Version 0.8.2 ()
 ------------------------------------------------------------------------
 
+    * Fix Plugin API call performing too many unneeded SQL queries
+      (garvinhicking)
+
     * Fix missing authorname when previewing entry. Thanks to winkiller,
       aquatic, thomas, wurstprinz and hansi for fixing this!
 
index f6cbd104fe57c42bb9ad8d24acbfabd446b40d73..b6a75b5760fc1d221057eb3f9b1d243fe107d10d 100644 (file)
@@ -295,6 +295,17 @@ class serendipity_plugin_api {
         return 0;
     }
 
+    function includePlugin($name, $pluginPath = '') {
+        global $serendipity;
+
+        // First try the local path, and then (if existing) a shared library repository ...
+        if (file_exists($serendipity['serendipityPath'] . 'plugins/' . $pluginPath . '/' . $name . '.php')) {
+            include $serendipity['serendipityPath'] . 'plugins/' . $pluginPath . '/' . $name . '.php';
+        } elseif (file_exists(S9Y_INCLUDE_PATH . 'plugins/' . $pluginPath . '/' . $name . '.php')) {
+            include S9Y_INCLUDE_PATH . 'plugins/' . $pluginPath . '/' . $name . '.php';
+        }
+    }
+
     /* Creates an instance of a named plugin */
     function &load_plugin($instance_id, $authorid = null, $pluginPath = '')
     {
@@ -307,29 +318,23 @@ class serendipity_plugin_api {
             $class_name = substr($name, 1);
         } else {
             /* plugin from the plugins/ dir */
-            if (!class_exists($name)) {
-                if (empty($pluginPath)) {
-                    $sql = "SELECT path from {$serendipity['dbPrefix']}plugins WHERE name = '" . $instance_id . "'";
-                    $plugdata = serendipity_db_query($sql, true, 'both', false, false, false, true);
-                    if (is_array($plugdata) && isset($plugdata[0])) {
-                        $pluginPath = $plugdata[0];
-                    }
-
-                    if (empty($pluginPath)) {
-                        $pluginPath = $name;
-                    }
+            serendipity_plugin_api::includePlugin($name, $pluginPath);
+            if (!class_exists($name) && empty($pluginPath)) {
+                $sql = "SELECT path from {$serendipity['dbPrefix']}plugins WHERE name = '" . $instance_id . "'";
+                $plugdata = serendipity_db_query($sql, true, 'both', false, false, false, true);
+                if (is_array($plugdata) && isset($plugdata[0])) {
+                    $pluginPath = $plugdata[0];
                 }
 
-                // First try the local path, and then (if existing) a shared library repository ...
-                if (file_exists($serendipity['serendipityPath'] . 'plugins/' . $pluginPath . '/' . $name . '.php')) {
-                    include $serendipity['serendipityPath'] . 'plugins/' . $pluginPath . '/' . $name . '.php';
-                } elseif (file_exists(S9Y_INCLUDE_PATH . 'plugins/' . $pluginPath . '/' . $name . '.php')) {
-                    include S9Y_INCLUDE_PATH . 'plugins/' . $pluginPath . '/' . $name . '.php';
+                if (empty($pluginPath)) {
+                    $pluginPath = $name;
                 }
+        
+                serendipity_plugin_api::includePlugin($name, $pluginPath);
+            }
 
-                if (!class_exists($name)) {
-                    return false;
-                }
+            if (!class_exists($name)) {
+                return false;
             }
 
             $class_name =& $name;