Thanks to visit codestin.com
Credit goes to github.com

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

Conversation

mateuszsip
Copy link
Contributor

@mateuszsip mateuszsip commented Oct 1, 2017

Q A
Branch? 4.1
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? yes
Tests pass? yes
Fixed tickets #24347
License MIT

Implements #24347.

Deprecating TraceableEventDispatcherInterface.

@nicolas-grekas
Copy link
Member

The BC break should be removed, as we have a policy of not doing hard BC break: any future BC break needs to be announced with a runtime deprecation notice in 3.4.
So, the addition to the interface must be reverted, and another way should be found.

Which makes me wonder BTW: do we need TraceableEventDispatcherInterface at all? Is it really something we want ppl to be able to implement on their own? If no, then let's just deprecate it.

@nicolas-grekas nicolas-grekas added this to the 3.4 milestone Oct 2, 2017
@stof
Copy link
Member

stof commented Oct 2, 2017

I think we could deprecate the interface

// THEN
$this->assertEmpty($events);

// SCENARIO - Returns orphaned event
Copy link
Member

Choose a reason for hiding this comment

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

different scenarios should be different tests (so that a failure in the first oen does not prevent others from running)

@mateuszsip
Copy link
Contributor Author

@stof @nicolas-grekas
Deprecated TraceableEventDispatcherInterface.

@nicolas-grekas
Copy link
Member

Moving to 4.1. Rebase on master might be needed, where PHP 7.1 features can be used btw.

@nicolas-grekas nicolas-grekas modified the milestones: 3.4, 4.1 Oct 8, 2017
@mateuszsip mateuszsip force-pushed the feature/orphaned-events branch from ed8fa01 to 5fdb763 Compare October 13, 2017 23:54
@mateuszsip
Copy link
Contributor Author

Rebased, updated changelogs and TraceableEventDispatcherInterface deprecation notice with new target version.

@mateuszsip
Copy link
Contributor Author

@stof could you check updated code?

Tests failure looks unrelated.

@@ -52,9 +53,10 @@ public function reset()

public function lateCollect()
{
if ($this->dispatcher instanceof TraceableEventDispatcherInterface) {
if ($this->dispatcher instanceof TraceableEventDispatcher) {
Copy link
Contributor

Choose a reason for hiding this comment

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

wanted? What about an additional instanceof check before calling setOrphanedEvents.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good question.
I went this way because TraceableEventDispatcherInterface gets depracted anyway.

@nicolas-grekas, what do you think?

Copy link
Member

Choose a reason for hiding this comment

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

Legacy code should continue to work

@@ -252,6 +254,10 @@ protected function postDispatch($eventName, Event $event)

private function preProcess($eventName)
{
if (false === $this->dispatcher->hasListeners($eventName)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

!$this->dispatcher->has...

@@ -252,6 +254,10 @@ protected function postDispatch($eventName, Event $event)

private function preProcess($eventName)
{
if (false === $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

*/
public function setCalledListeners(array $listeners)
{
$this->data['called_listeners'] = $listeners;
}

/**
* Gets the called listeners.
Copy link
Contributor

Choose a reason for hiding this comment

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

the diff is kinda messy... cant we avoid it by simply appending set+get (which seem to be the pattern anyway).

@mateuszsip
Copy link
Contributor Author

Thanks @ro0NL for review.
Fixed everything you catched, including separate TraceableEventDispatcher check to not break code relying on TraceableEventDispatcherInterface.

Copy link
Contributor

@ro0NL ro0NL left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@@ -88,7 +95,7 @@ public function getCalledListeners()
*
* @param array $listeners An array of not called listeners
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

*/
public function getNotCalledListeners()
{
return $this->data['not_called_listeners'];
}

/**
* Sets the orphaned events.
*
* @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

Copy link
Contributor

@Simperfit Simperfit left a comment

Choose a reason for hiding this comment

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

left 2 minor comments but LGTM

@mateuszsip mateuszsip force-pushed the feature/orphaned-events branch from 09a0fa1 to e18f77c Compare November 1, 2017 00:25
@mateuszsip
Copy link
Contributor Author

rebased

@xabbuh
Copy link
Member

xabbuh commented Nov 7, 2017

deprecations will have to be documented in the UPGRADE-4.1.md and UPGRADE-5.0.md(to be created) files

@mateuszsip mateuszsip force-pushed the feature/orphaned-events branch from e18f77c to fb16cfa Compare December 3, 2017 17:34
@mateuszsip
Copy link
Contributor Author

Rebased, deprecations documented in UPGRADE.

UPGRADE-4.1.md Outdated
@@ -1,6 +1,11 @@
UPGRADE FROM 4.0 to 4.1
=======================

Event Dispatcher
Copy link
Member

Choose a reason for hiding this comment

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

EventDispatcher (that's the name of the component :))

UPGRADE-4.1.md Outdated
@@ -1,6 +1,11 @@
UPGRADE FROM 4.0 to 4.1
=======================

Event Dispatcher
-----------
Copy link
Member

Choose a reason for hiding this comment

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

please use as many dashes as the length of the component's name

@mateuszsip mateuszsip force-pushed the feature/orphaned-events branch from fb16cfa to e53b7f3 Compare December 28, 2017 02:53
@mateuszsip
Copy link
Contributor Author

Thanks @xabbuh, I wasn't aware of that.

Rebased and corrected.

@fabpot
Copy link
Member

fabpot commented Jan 19, 2018

Thank you @kejwmen.

@fabpot fabpot closed this in 0a56a37 Jan 19, 2018
ostrolucky pushed a commit to ostrolucky/symfony that referenced this pull request Mar 25, 2018
This PR was squashed before being merged into the 4.1-dev branch (closes symfony#24392).

Discussion
----------

Display orphaned events in profiler

| Q             | A
| ------------- | ---
| Branch?       | 4.1
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | yes
| Tests pass?   | yes
| Fixed tickets | symfony#24347
| License       | MIT

Implements symfony#24347.

Deprecating `TraceableEventDispatcherInterface`.

Commits
-------

509f9a9 Display orphaned events in profiler
@fabpot fabpot mentioned this pull request May 7, 2018
fabpot added a commit that referenced this pull request Jul 12, 2018
…ont)

This PR was merged into the 4.1 branch.

Discussion
----------

[EventDispatcher] Clear orphaned events on reset

| Q             | A
| ------------- | ---
| Branch?       | 4.1
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | NA
| License       | MIT
| Doc PR        | NA

When the Orphaned Events feature was added in #24392 it was forgotten to also clear them when the `reset` method on the `TraceableEventDispatcher` is called. This makes the Orphaned Events tab on the Event profiler an evergrowing list when using PHP-PM (or other event loop implementations).

Commits
-------

d3260df [EventDispatcher] Clear orphaned events on TraceableEventDispatcher::reset
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants