[pLog-svn] r5390 - plog/branches/lifetype-1.2/class/plugin

jondaley at devel.lifetype.net jondaley at devel.lifetype.net
Fri May 11 00:04:49 EDT 2007


Author: jondaley
Date: 2007-05-11 00:04:49 -0400 (Fri, 11 May 2007)
New Revision: 5390

Modified:
   plog/branches/lifetype-1.2/class/plugin/pluginmanager.class.php
Log:
aha.  The problem wasn't that the plugin was being instantiated more than once, but once it was instantiated, it was being copied, so the _pluginEventList had a different copy of the class than the _pluginInstances.  I don't see any errors on php4 or php5 unless I turned on E_STRICT, which give tons of errors, so I think we don't care about those

Modified: plog/branches/lifetype-1.2/class/plugin/pluginmanager.class.php
===================================================================
--- plog/branches/lifetype-1.2/class/plugin/pluginmanager.class.php	2007-05-11 03:58:02 UTC (rev 5389)
+++ plog/branches/lifetype-1.2/class/plugin/pluginmanager.class.php	2007-05-11 04:04:49 UTC (rev 5390)
@@ -244,7 +244,7 @@
                	if( File::isReadable( $pluginFile."/".$pluginFileName )) {
 					$className = "Plugin".$plugin;
 					lt_include( $pluginFullPath );
-					$classInstance = new $className( $this->_source );						
+					$classInstance =& new $className( $this->_source );						
 					$classInstance->setPluginFolder( PLOG_CLASS_PATH.$pluginFile."/" );	
 					$name = $classInstance->getId();
 					
@@ -255,7 +255,7 @@
 
 					// create an instance only if the plugin is allowed to run in this version of LT					
 					if( $this->_pluginCanRun( $classInstance->getVersion())) {
-						$this->_pluginInstances["$name"] = &$classInstance;										
+						$this->_pluginInstances["$name"] = &$classInstance;
 					}
 				}
 			}
@@ -330,7 +330,10 @@
         function notifyEvent( $eventType, $params = Array())
         {
             // check if there is any plugin that wants to be notified about this event
-            $plugins = array_key_exists( $eventType, $this->_pluginEventList ) ? $this->_pluginEventList["$eventType"] : Array(); 
+            $plugins = Array();
+            if(array_key_exists( $eventType, $this->_pluginEventList ))
+                $plugins = $this->_pluginEventList["$eventType"];
+
             if( !is_array($plugins) || empty($plugins))
                 return $params;
 
@@ -356,7 +359,7 @@
          * @param pluginClass
          * @return Always true
          */
-        function registerNotification( $eventType, $pluginClass )
+        function registerNotification( $eventType, &$pluginClass )
         {
             // there can be more than one plugin registered for the same event,
             // so we need an array of plugin classes
@@ -365,7 +368,7 @@
             }
 
             // and then add the plugin to the list
-            $this->_pluginEventList["$eventType"][] = $pluginClass;
+            $this->_pluginEventList["$eventType"][] =& $pluginClass;
 
             return true;
         }



More information about the pLog-svn mailing list