Whoops. Fix major Spartacus borkage which couldn't fetch plugins.
authorgarvinhicking <garvinhicking>
Sat, 9 Jul 2005 12:46:24 +0000 (12:46 +0000)
committergarvinhicking <garvinhicking>
Sat, 9 Jul 2005 12:46:24 +0000 (12:46 +0000)
Added ultra-verbose debugging for the time spartacus is a bit experimental.
Will be removed again in the future because of performance reasons.

include/admin/plugins.inc.php
include/plugin_api.inc.php
plugins/serendipity_event_spartacus/serendipity_event_spartacus.php

index cbecfdb7a83b2c617e0cf6e2ddaa1b5f96d544b4..9d0b981243374c73331ad4e92bef200431ad512c 100644 (file)
@@ -725,10 +725,15 @@ if (isset($_GET['serendipity']['plugin_to_conf'])) {
         serendipity_plugin_api::hook_event('backend_plugins_fetchplugin', $fetchplugin_data);
 
         if ($fetchplugin_data['install']) {
+            $serendipity['debug']['pluginload'] = array();
             $inst = serendipity_plugin_api::create_plugin_instance($serendipity['GET']['install_plugin'], null, (serendipity_plugin_api::is_event_plugin($serendipity['GET']['install_plugin']) ? 'event': 'right'), $authorid, serendipity_db_escape_string($serendipity['GET']['pluginPath']));
 
             /* Load the new plugin */
             $plugin = &serendipity_plugin_api::load_plugin($inst);
+            if (!is_object($plugin)) {
+                echo "DEBUG: Plugin $inst not an object: " . print_r($plugin, true) . ".<br />Input: " . print_r($serendipity['GET'], true) . ".<br /><br />\n\nPlease report this bug. This error can happen if a plugin was not properly downloaded (check your plugins directory if the requested plugin was downloaded) or the inclusion of a file failed (permissions?)<br />\n";
+                echo "Backtrace:<br />\n" . implode("<br />\n", $serendipity['debug']['pluginload']) . "<br />";
+            }
             $bag  = new serendipity_property_bag;
             $plugin->introspect($bag);
 
index b03821c42241df9d47aa79426cc82a24e852ef0b..707c39f398c441b99007488cce323c23fee39954 100644 (file)
@@ -79,7 +79,11 @@ class serendipity_plugin_api {
             $nextidx = 0;
         }
 
-        serendipity_db_query("INSERT INTO {$serendipity['dbPrefix']}plugins (name, sort_order, placement, authorid, path) values ('$key', $nextidx, '$default_placement', '$authorid', '$pluginPath')");
+        $serendipity['debug']['pluginload'][] = "Installing plugin: " . print_r(func_get_args(), true);
+
+        $iq = "INSERT INTO {$serendipity['dbPrefix']}plugins (name, sort_order, placement, authorid, path) values ('$key', $nextidx, '$default_placement', '$authorid', '$pluginPath')";
+        $serendipity['debug']['pluginload'][] = $iq;
+        serendipity_db_query($iq);
         serendipity_plugin_api::hook_event('backend_plugins_new_instance', $key, array('default_placement' => $default_placement));
 
         /* Check for multiple dependencies */
@@ -91,6 +95,7 @@ class serendipity_plugin_api {
             $plugin->register_dependencies(false, $authorid);
             $plugin->install();
         } else {
+            $serendipity['debug']['pluginload'][] = "Loading plugin failed painfully. File not found?";
             echo ERROR . ': ' . $key . ' (' . $pluginPath . ')<br />';
         }
 
@@ -350,8 +355,10 @@ class serendipity_plugin_api {
 
         if (!$is_internal) {
             /* plugin from the plugins/ dir */
+            $serendipity['debug']['pluginload'][] = "Including plugin $class_name, $pluginPath";
             $filename = serendipity_plugin_api::includePlugin($class_name, $pluginPath);
             if (empty($filename) && !empty($instance_id)) {
+                $serendipity['debug']['pluginload'][] = "No valid path/filename found.";
                 $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])) {
@@ -362,14 +369,17 @@ class serendipity_plugin_api {
                     $pluginPath = $class_name;
                 }
         
+                $serendipity['debug']['pluginload'][] = "Including plugin(2) $class_name, $pluginPath";
                 $filename = serendipity_plugin_api::includePlugin($class_name, $pluginPath);
             }
 
             if (empty($filename)) {
+                $serendipity['debug']['pluginload'][] = "No valid path/filename found. Aborting.";
                 return false;
             }
         }
 
+        $serendipity['debug']['pluginload'][] = "Found plugin file $filename";
         return $filename;
     }
     
@@ -379,20 +389,25 @@ class serendipity_plugin_api {
 
         if ($pluginFile === null) {
             $class_name = '';
+            $serendipity['debug']['pluginload'][] = "Init probe for plugin $instance_id, $class_name, $pluginPath";
             $pluginFile = serendipity_plugin_api::probePlugin($instance_id, $class_name, $pluginPath);
         } else {
             $is_internal = false;
+            $serendipity['debug']['pluginload'][] = "getClassByInstanceID $instance_id, $is_internal";
             $class_name  = serendipity_plugin_api::getClassByInstanceID($instance_id, $is_internal);
         }
         
         if (!class_exists($class_name) && !empty($pluginFile)) {
+            $serendipity['debug']['pluginload'][] = "Classname does not exist. Including $pluginFile.";
             include_once($pluginFile);
         }
 
         if (!class_exists($class_name)) {
+            $serendipity['debug']['pluginload'][] = "Classname $class_name still does not exist. Aborting.";
             return false;
         }
         
+        $serendipity['debug']['pluginload'][] = "Returning new $class_name($instance_id)";
         $p =& new $class_name($instance_id);
         if (!is_null($authorid)) {
             $p->serendipity_owner = $authorid;
index 47120c5b60d459a03de61e85e269730b94a3c2be..d837d66cb5adddc5ecc3217e483e3cd6b5d6efb4 100644 (file)
@@ -596,6 +596,7 @@ class serendipity_event_spartacus extends serendipity_event
         $found = false;
 
         $this->checkArray($tree);
+        print_r($tree);
 
         foreach($tree[0]['children'] AS $idx => $subtree) {
             if ($subtree['tag'] != 'package') {
@@ -603,7 +604,9 @@ class serendipity_event_spartacus extends serendipity_event
             }
 
             foreach($subtree['children'] AS $child => $childtree) {
-                if ($childtree['tag'] == 'template' && $childtree['value'] == $plugin_to_install) {
+                if ($sub == 'templates' && $childtree['tag'] == 'template' && $childtree['value'] == $plugin_to_install) {
+                    $found = true;
+                } elseif ($sub == 'plugins' && $childtree['tag'] == 'name' && $childtree['value'] == $plugin_to_install) {
                     $found = true;
                 }