8000 [2.2] added a way to enable the profiler for the very next request in a functional test by fabpot · Pull Request #4897 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[2.2] added a way to enable the profiler for the very next request in a functional test #4897

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

Merged
merged 4 commits into from
Sep 18, 2012

Conversation

fabpot
Copy link
Member
@fabpot fabpot commented Jul 13, 2012

Bug fix: yes/no
Feature addition: yes
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets: #4307
Todo: -
License of the code: MIT
Documentation PR: should be done before merging

After merging this PR, we need to disable the profiler in the test environment in Symfony SE.

fabpot added a commit to symfony/symfony-docs that referenced this pull request Sep 18, 2012
fabpot added a commit that referenced this pull request Sep 18, 2012
Commits
-------

22e9036 updated CHANGELOG
bafe890 [FrameworkBundle] changed Client::enableProfiler() behavior to fail silently when the profiler is not available (it makes it easier to write functional tests)
f41872b [FrameworkBundle] added a way to enable the profiler for the very next request in functional tests (closes #4307)
67b91e5 [HttpKernel] added a way to enable a disable Profiler

Discussion
----------

[2.2] added a way to enable the profiler for the very next request in a functional test

Bug fix: yes/no
Feature addition: yes
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets: #4307
Todo: -
License of the code: MIT
Documentation PR: should be done before merging

After merging this PR, we need to disable the profiler in the test environment in Symfony SE.
@f
8000
abpot fabpot merged commit 22e9036 into symfony:master Sep 18, 2012
$this->profiler = false;

$this->kernel->boot();
$this->kernel->getContainer()->get('profiler')->enable();
Copy link
Contributor

Choose a reason for hiding this comment

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

this is not really safe to call as the profiler could be removed between enableProfiler and request.

Copy link
Member

Choose a reason for hiding this comment

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

what do you mean ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Client::enableProfiler() with profiler existing
profiler service is removed from the container
Client::request() -> fatal error, although it should just continue without profiling

Copy link
Contributor

Choose a reason for hiding this comment

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

I just recognize an even bigger problem: $this->kernel is type hinted as HttpKernelInterface in Symfony\Component\HttpKernel\Client
But here you assume kernel is a KernelInterface which is not necessarily true. HttpKernelInterface does not provide ->getContrainer at all.

Copy link
Member

Choose a reason for hiding this comment

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

@Tobion the code in other places is already expecting a kernel as it calls the container and the boot.

And you cannot remove a service from a container.

Copy link
Contributor

Choose a reason for hiding this comment

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

Either the type hint in https://github.com/symfony/symfony/blob/master/src/Symfony/Component/HttpKernel/Client.php#L43 is wrong.
Or this subclass must make sure that a KernelInterface is passed. Otherwise this code is wrong.

And you can remove a service from a container with Container::set('profiler', null).

Copy link
Member

Choose a reason for hiding this comment

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

well, the client class available in HttpKernel is right about its typehint. It only expects an HttpKernelInterface (and Silex can use it for instance).

And no. Container::set('profiler', null) does not remove the service from the container. It removes the instance if it was already created, meaning requesting the service will have to create a new instance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0