use unoptimized dispatcher
authordemeritcowboy <demeritcowboy@hotmail.com>
Fri, 19 Aug 2022 00:18:29 +0000 (20:18 -0400)
committerdemeritcowboy <demeritcowboy@hotmail.com>
Fri, 11 Nov 2022 19:27:46 +0000 (14:27 -0500)
Civi/Core/CiviEventDispatcher.php
Civi/Core/UnoptimizedEventDispatcher.php [new file with mode: 0644]

index 11c7c048a7376b5d185429a568a6d3075e35f708..054bd766753718cfc00408c2be4775c6895fde90 100644 (file)
@@ -4,7 +4,6 @@ namespace Civi\Core;
 
 use Civi\Core\Event\GenericHookEvent;
 use Civi\Core\Event\HookStyleListener;
-use Symfony\Component\EventDispatcher\EventDispatcher;
 use Symfony\Component\EventDispatcher\EventSubscriberInterface;
 
 /**
@@ -61,7 +60,7 @@ class CiviEventDispatcher implements CiviEventDispatcherInterface {
    * Constructor
    */
   public function __construct() {
-    $this->dispatcher = new EventDispatcher();
+    $this->dispatcher = new UnoptimizedEventDispatcher();
   }
 
   /**
diff --git a/Civi/Core/UnoptimizedEventDispatcher.php b/Civi/Core/UnoptimizedEventDispatcher.php
new file mode 100644 (file)
index 0000000..01fa40b
--- /dev/null
@@ -0,0 +1,18 @@
+<?php
+
+namespace Civi\Core;
+
+use Symfony\Component\EventDispatcher\EventDispatcher;
+
+/**
+ * Class UnoptimizedEventDispatcher
+ * @package Civi\Core
+ *
+ * Since symfony 4.3, the EventDispatcher contains optimization code that
+ * converts all functions into closures. This causes test runs to crash.
+ * Until we can figure out why this simply skips the optimization which is
+ * roughly the same as before 4.3. The optimization is skipped if the object
+ * being instantiated is not the base class EventDispatcher (https://github.com/symfony/event-dispatcher/blob/75f99d7489409207d09c6cd75a6c773ccbb516d5/EventDispatcher.php#L41)
+ */
+class UnoptimizedEventDispatcher extends EventDispatcher {
+}