Commit 86e3b8f4 authored by lussoluca's avatar lussoluca Committed by lussoluca

Issue #2914657 by lussoluca: Cannot use object of type Closure as array

parent 46ab1195
......@@ -170,10 +170,18 @@ class TraceableEventDispatcher extends ContainerAwareEventDispatcher implements
* @param $priority
*/
private function addCalledListener($definition, $event_name, $priority) {
$this->calledListeners[$event_name][$priority][] = [
'class' => get_class($definition['callable'][0]),
'method' => $definition['callable'][1],
];
if ($this->isClosure($definition['callable'])) {
$this->calledListeners[$event_name][$priority][] = [
'class' => 'Closure',
'method' => '',
];
}
else {
$this->calledListeners[$event_name][$priority][] = [
'class' => get_class($definition['callable'][0]),
'method' => $definition['callable'][1],
];
}
foreach ($this->notCalledListeners[$event_name][$priority] as $key => $listener) {
if (isset($listener['service'])) {
......@@ -182,12 +190,25 @@ class TraceableEventDispatcher extends ContainerAwareEventDispatcher implements
}
}
else {
if (get_class($listener['callable'][0]) == get_class($definition['callable'][0]) && $listener['callable'][1] == $definition['callable'][1]) {
unset($this->notCalledListeners[$event_name][$priority][$key]);
if ($this->isClosure($listener['callable'])) {
if (is_callable($listener['callable'], TRUE, $listenerCallableName) && is_callable($definition['callable'], TRUE, $definitionCallableName)) {
if ($listenerCallableName == $definitionCallableName) {
unset($this->notCalledListeners[$event_name][$priority][$key]);
}
}
}
else {
if (get_class($listener['callable'][0]) == get_class($definition['callable'][0]) && $listener['callable'][1] == $definition['callable'][1]) {
unset($this->notCalledListeners[$event_name][$priority][$key]);
}
}
}
}
}
private function isClosure($t) {
return is_object($t) && ($t instanceof \Closure);
}
}
......@@ -44,7 +44,13 @@
<tr>
<td><%= event_name %></td>
<% if( listener.clazz ) { %>
<td><%= Drupal.webprofiler.helpers.classLink(listener.clazz) %></td>
<td>
<% if( listener.class == "Closure" ) { %>
<%= "Closure" %>
<% } else { %>
<%= Drupal.webprofiler.helpers.classLink(listener.clazz) %>
<% } %>
</td>
<% } else { %>
<td><%= listener.service[0] %>::<%= listener.service[1] %></td>
<% } %>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment