8000 Display orphaned events in profiler by mateuszsip · Pull Request #24392 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Display orphaned events in profiler #24392

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
removed getOrphanedEvents from TraceableEventDispatcherInterface, int…
…roduced interface deprecation
  • Loading branch information
mateuszsip committed Dec 28, 2017
commit 59c8adf37f696127bfd90c8b6c63f3e6c16464eb
6 changes: 5 additions & 1 deletion src/Symfony/Bundle/WebProfilerBundle/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
CHANGELOG
=========

4.0.0
4.1.0
-----

* added information about orphaned events

4.0.0
-----

* removed the `WebProfilerExtension::dumpValue()` method
* removed the `getTemplates()` method of the `TemplateManager` class in favor of the ``getNames()`` method
* removed the `web_profiler.position` config option and the
Expand Down
6 changes: 5 additions & 1 deletion src/Symfony/Component/EventDispatcher/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
CHANGELOG
=========

4.1.0
-----

* The method `TraceableEventDispatcher::getOrphanedEvents()` has been added.

4.0.0
-----

* The method `EventDispatcherInterface::getOrphanedEvents()` has been added.
* removed the `ContainerAwareEventDispatcher` class
* added the `reset()` method to the `TraceableEventDispatcherInterface`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,16 @@ public function getNotCalledListeners()
return $notCalled;
}

/**
* Gets the orphaned events.
*
* @return array An array of orphaned events
*/
public function getOrphanedEvents()
{
return $this->orphanedEvents;
}

public function reset()
{
$this->called = array();
Expand Down Expand Up @@ -249,8 +259,10 @@ protected function postDispatch($eventName, Event $event)

private function preProcess($eventName)
{
if (false === $this->dispatcher->hasListeners($eventName)) {
if (!$this->dispatcher->hasListeners($eventName)) {
$this->orphanedEvents[] = $eventName;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return; here


return;
}

foreach ($this->dispatcher->getListeners($eventName) as $listener) {
Expand Down Expand Up @@ -325,14 +337,4 @@ private function sortListenersByPriority($a, $b)

return 1;
}

/**
* Gets the orphaned events.
*
* @return array An array of orphaned events
*/
public function getOrphanedEvents()
{
return $this->orphanedEvents;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
use Symfony\Component\EventDispatcher\EventDispatcherInterface;

/**
* @deprecated since version 4.1, will be removed in 5.0.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
interface TraceableEventDispatcherInterface extends EventDispatcherInterface
Expand All @@ -36,11 +38,4 @@ public function getNotCalledListeners();
* Resets the trace.
*/
public function reset();

/**
* Gets the orphaned events.
*
* @return array An array of orphaned events
*/
public function getOrphanedEvents();
}
2 changes: 1 addition & 1 deletion src/Symfony/Component/HttpKernel/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ CHANGELOG
4.1.0
-----

* added orphaned events support to `EventDataCollector`
* `ExceptionListener` now logs and collects exceptions at priority `2048` (previously logged at `-128` and collected at `0`)

4.0.0
Expand Down Expand Up @@ -33,7 +34,6 @@ CHANGELOG
3.4.0
-----

* added orphaned events support to `EventDataCollector`
* added a minimalist PSR-3 `Logger` class that writes in `stderr`
* made kernels implementing `CompilerPassInterface` able to process the container
* deprecated bundle inheritance
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace Symfony\Component\HttpKernel\DataCollector;

use Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher;
use Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcherInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
Expand Down Expand Up @@ -53,11 +54,15 @@ public function reset()

public function lateCollect()
{
if ($this->dispatcher instanceof TraceableEventDispatcher) {
if ($this->dispatcher instanceof TraceableEventDispatcherInterface) {
$this->setCalledListeners($this->dispatcher->getCalledListeners());
$this->setNotCalledListeners($this->dispatcher->getNotCalledListeners());< F438 /span>
}

if ($this->dispatcher instanceof TraceableEventDispatcher) {
$this->setOrphanedEvents($this->dispatcher->getOrphanedEvents());
}

$this->data = $this->cloneVar($this->data);
}

Expand All @@ -74,51 +79,51 @@ public function setCalledListeners(array $listeners)
}

/**
* Sets the not called listeners.
* Gets the called listeners.
*
* @param array $listeners An array of not called listeners
* @return array An array of called listeners
*
* @see TraceableEventDispatcher
*/
public function setNotCalledListeners(array $listeners)
public function getCalledListeners()
{
$this->data['not_called_listeners'] = $listeners;
return $this->data['called_listeners'];
}

/**
* Sets the orphaned events.
* Sets the not called listeners.
*
* @param array $events An array of orphaned events
* @param array $listeners
*
* @see TraceableEventDispatcher
*/
public function setOrphanedEvents(array $events)
public function setNotCalledListeners(array $listeners)
{
$this->data['orphaned_events'] = $events;
$this->data['not_called_listeners'] = $listeners;
}

/**
* Gets the called listeners.
* Gets the not called listeners.
*
* @return array An array of called listeners
* @return array
*
* @see TraceableEventDispatcher
*/
public function getCalledListeners()
public function getNotCalledListeners()
{
return $this->data['called_listeners'];
return $this->data['not_called_listeners'];
}

/**
* Gets the not called listeners.
* Sets the orphaned events.
*
* @return array An array of not called listeners
* @param array $events An array of orphaned events
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems useless too

*
* @see TraceableEventDispatcher
*/
public function getNotCalledListeners()
public function setOrphanedEvents(array $events)
{
return $this->data['not_called_listeners'];
$this->data['orphaned_events'] = $events;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@

namespace Symfony\Component\HttpKernel\Tests\Fixtures;

use Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcherInterface;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher;

class TestEventDispatcher extends EventDispatcher implements TraceableEventDispatcherInterface
class TestEventDispatcher extends TraceableEventDispatcher
{
public function getCalledListeners()
{
Expand Down
0