diff --git a/core/lib/Drupal/Core/EventListenerPass.php b/core/lib/Drupal/Core/EventListenerPass.php index a00a644..54973cf 100644 --- a/core/lib/Drupal/Core/EventListenerPass.php +++ b/core/lib/Drupal/Core/EventListenerPass.php @@ -66,8 +66,8 @@ public function process(ContainerBuilder $container) { */ protected function findListeners(ContainerBuilder $container, Definition $event_dispatcher_definition, ModuleHandlerInterface $module_handler) { foreach ($this->getYamlDiscovery($module_handler)->findAll() as $info) { - foreach ($info['subscribers'] as $event_id => $listeners) { - foreach ($listeners as $listener) { + foreach ((array) $info['subscribers'] as $event_id => $listeners) { + foreach ((array) $listeners as $listener) { if ($result = $this->prepareListener($container, $event_id, $listener)) { list($add_method, $args) = $result; $event_dispatcher_definition->addMethodCall($add_method, $args); diff --git a/core/tests/Drupal/Tests/Core/EventListenerPassTest.php b/core/tests/Drupal/Tests/Core/EventListenerPassTest.php index 39a7375..f3a43ee 100644 --- a/core/tests/Drupal/Tests/Core/EventListenerPassTest.php +++ b/core/tests/Drupal/Tests/Core/EventListenerPassTest.php @@ -356,6 +356,24 @@ public function testInvalidYaml() { $this->eventListenerPass->process($container); } + /** + * Tests the evnet listener pass with an yaml file without any subscribers. + */ + public function testEmptyYaml() { + $container = $this->setUpContainer(); + + $info['subscribers'] = NULL; + $yaml_discovery = $this->getMock('Drupal\Component\Discovery\DiscoverableInterface'); + $yaml_discovery->expects($this->once()) + ->method('findAll') + ->will($this->returnValue(array($info))); + + $this->eventListenerPass->setYamlDiscovery($yaml_discovery); + $this->eventListenerPass->process($container); + $definition = $container->getDefinition('event_dispatcher'); + $this->assertEquals(array(), $definition->getMethodCalls()); + } + } class TestEventListenerPass extends EventListenerPass {