]> 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:47 +0000 (14:39 +0000)
committergarvinhicking <garvinhicking>
Thu, 19 May 2005 14:39:47 +0000 (14:39 +0000)
That sucks, we'll need to release 0.8.2 soon then.

docs/NEWS
include/plugin_api.inc.php

index 873849162fd5a9022716b5a384e22945ca857e10..7589581c40086d0f0fa7720901b94eed94efab36 100644 (file)
--- a/docs/NEWS
+++ b/docs/NEWS
@@ -1,8 +1,11 @@
-# $Id$
+svn di# $Id$
 
 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 9b66da438ffc5facf10fc5908a7d4bd36dadbd4d..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;
@@ -408,6 +413,9 @@ class serendipity_plugin_api {
         }
 
         $pluginData = array();
+        $addData    = func_get_args();
+        serendipity_plugin_api::hook_event('frontend_generate_plugins', $plugins, $addData);
+
         foreach ($plugins as $plugin_data) {
             $plugin =& serendipity_plugin_api::load_plugin($plugin_data['name'], $plugin_data['authorid'], $plugin_data['path']);
             if (is_object($plugin)) {