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

Skip to content

[Messenger] Clone messages to show in profiler #26650

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 4 commits into from

Conversation

Nyholm
Copy link
Member

@Nyholm Nyholm commented Mar 23, 2018

Q A
Branch? master
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets na
License MIT
Doc PR na

We should make the profiler page more pretty by using the cloner.

screen shot 2018-03-23 at 11 08 02

@@ -50,10 +60,9 @@

{% block toolbar %}
{% set color_code = 'normal' %}
{% set message_count = 0 %}
Copy link
Member Author

Choose a reason for hiding this comment

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

@sroze Any reason why this was zero?

Copy link
Contributor

Choose a reason for hiding this comment

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

Nop, very likely a mistake 🙊

@@ -31,7 +31,13 @@
<tbody>
{% for message in collector.messages %}
<tr>
<td>{{ message.message.type }}</td>
<td>
{{ message.message.type }}
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't believe we still need to display the type anymore if we use the dumper, as the FQCN is available as overlay :)

@@ -40,6 +46,10 @@
{% if message.exception.type is defined %}
{{ message.exception.type }}
{% endif %}

{% if message.result.object is defined %}
Copy link
Contributor

Choose a reason for hiding this comment

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

Same idea. If defined, I'd display this instead of the message.result.type.

@@ -50,10 +60,9 @@

{% block toolbar %}
{% set color_code = 'normal' %}
{% set message_count = 0 %}
Copy link
Contributor

Choose a reason for hiding this comment

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

Nop, very likely a mistake 🙊

@Nyholm
Copy link
Member Author

Nyholm commented Mar 23, 2018

Thank you for the review

screen shot 2018-03-23 at 11 27 31

@@ -63,6 +64,7 @@ public function handle($message, callable $next)
if (is_object($result)) {
$debugRepresentation['result'] = array(
'type' => get_class($result),
'object' => $this->cloneVar($result),
);
} else {
Copy link
Member

Choose a reason for hiding this comment

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

should be cloned as well in case it is an array, as it might contain objects inside the array

Copy link
Member

Choose a reason for hiding this comment

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

btw, the template does not seem to use the value in this case when rendering the info, so why storing it ?

@chalasr chalasr added this to the 4.1 milestone Mar 23, 2018
@stof
Copy link
Member

stof commented Mar 23, 2018

IMO, messages should not be stored directly in $this->data in the collector, as this forbids us to store anything else in the future in this collector in case we need to collect more things. You should probably move this to $this->data['messages'] instead.

@Nyholm
Copy link
Member Author

Nyholm commented Mar 23, 2018

Thank you for the review

Copy link
Contributor

@sroze sroze left a comment

Choose a reason for hiding this comment

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

Looks good to me 👍 (after squashing the commits, obsly)

@sroze
Copy link
Contributor

sroze commented Mar 26, 2018

@Nyholm could you squash your commits?
@stof can you have another look please?

@Nyholm Nyholm force-pushed the message-profiler-clone branch from 5700de0 to 52f4da9 Compare March 26, 2018 10:40
@Nyholm
Copy link
Member Author

Nyholm commented Mar 26, 2018

Done

Copy link
Contributor

@sroze sroze left a comment

Choose a reason for hiding this comment

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

Failure in un-related 👍

@@ -77,7 +84,7 @@ public function handle($message, callable $next)
);
}

$this->data[] = $debugRepresentation;
$this->data['messages'][] = $debugRepresentation;
Copy link
Member

Choose a reason for hiding this comment

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

collect must ensure that $this->data['messages'] is always an array, even when no message was handled there, to make getMessages work without notice after collect has been called.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thank you

Copy link
Contributor

Choose a reason for hiding this comment

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

@Nyholm your changes did not fix this btw 😉

Copy link
Member Author

Choose a reason for hiding this comment

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

Doesn't it?
Cant I trust that $this->data always to be null or an array?

https://3v4l.org/tubTL

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, you're right, it won't "throw" a PHP notice.

@@ -77,7 +84,7 @@ public function handle($message, callable $next)
);
}

$this->data[] = $debugRepresentation;
$this->data['messages'][] = $debugRepresentation;
Copy link
Contributor

Choose a reason for hiding this comment

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

@Nyholm your changes did not fix this btw 😉

@@ -77,7 +84,7 @@ public function handle($message, callable $next)
);
}

$this->data[] = $debugRepresentation;
$this->data['messages'][] = $debugRepresentation;
Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, you're right, it won't "throw" a PHP notice.

@@ -88,6 +95,10 @@ public function handle($message, callable $next)

public function getMessages(): array
{
return $this->data;
if (!isset($this->data['messages'])) {
Copy link
Contributor

Choose a reason for hiding this comment

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

return $this->data['messages'] ?? array();

(note the array(), this will make fabbot happy)

@Nyholm
Copy link
Member Author

Nyholm commented Mar 26, 2018

Thank you

@Nyholm Nyholm force-pushed the message-profiler-clone branch from ff354df to 359a658 Compare March 27, 2018 07:37
@Nyholm
Copy link
Member Author

Nyholm commented Mar 27, 2018

I've rebased this PR now. Im ready for a final review.

@fabpot
Copy link
Member

fabpot commented Mar 27, 2018

Thank you @Nyholm.

@fabpot fabpot closed this Mar 27, 2018
fabpot added a commit that referenced this pull request Mar 27, 2018
This PR was squashed before being merged into the 4.1-dev branch (closes #26650).

Discussion
----------

[Messenger] Clone messages to show in profiler

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

We should make the profiler page more pretty by using the cloner.

![screen shot 2018-03-23 at 11 08 02](https://user-images.githubusercontent.com/1275206/37823687-816a373a-2e8a-11e8-824e-ac7f96a51e3b.png)

Commits
-------

4d1be87 [Messenger] Clone messages to show in profiler
@Nyholm Nyholm deleted the message-profiler-clone branch March 27, 2018 07:52
@fabpot fabpot mentioned this pull request May 7, 2018
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.

6 participants