From b4b649eeb6ecc07b585d4b091224e49811149760 Mon Sep 17 00:00:00 2001
From: Cameron <e107inc@gmail.com>
Date: Sat, 7 Mar 2020 10:00:12 -0800
Subject: [PATCH] Fixes #4079 - Corrected multiple event includes conflict.

---
 e107_handlers/event_class.php | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/e107_handlers/event_class.php b/e107_handlers/event_class.php
index 75cc3e5e2..9f33e2515 100644
--- a/e107_handlers/event_class.php
+++ b/e107_handlers/event_class.php
@@ -140,13 +140,15 @@ class e107_event
 	 */
 	function register($eventname, $function, $include='')
 	{
-		$this->includes[$eventname] = array();
+
+
 		if(!isset($this->functions[$eventname]) || !in_array($function, $this->functions[$eventname]))
 		{
 			if (!empty($include))
 			{
 				$this->includes[$eventname][] = $include;
 			}
+
 			$this->functions[$eventname][] = $function;
 		}
 	}
@@ -155,11 +157,12 @@ class e107_event
 
 	function debug()
 	{
-		echo "<h3>Event Functions</h3>";
-		print_a($this->functions);
-		echo "<h3>Event Includes</h3>";
-		print_a($this->includes);	
-		
+		$text = "<h3>Event Functions</h3>";
+		$text .= print_a($this->functions,true);
+		$text .= "<h3>Event Includes</h3>";
+		$text .= print_a($this->includes,true);
+
+		return $text;
 	}
 
 
@@ -182,6 +185,10 @@ class e107_event
 				}
 			}
 		}*/
+
+	//	echo ($this->debug());
+
+
 		if (isset($this->functions[$eventname]))
 		{
 			foreach($this->functions[$eventname] as $i => $evt_func)
@@ -190,9 +197,12 @@ class e107_event
 				if(isset($this->includes[$eventname][$i])) //no checks
 				{
 					$location = $this->includes[$eventname][$i];
+
 					e107_include_once($location); 
 					unset($this->includes[$eventname][$i]);
+
 				}
+
 				if(is_array($evt_func)) //class, method
 				{
 					$class = $evt_func[0];