Skip to content

Commit

Permalink
bug #32173 [FrameworkBundle] Fix calling Client::getProfile() before …
Browse files Browse the repository at this point in the history
…sending a request (dunglas)

This PR was merged into the 3.4 branch.

Discussion
----------

[FrameworkBundle] Fix calling Client::getProfile() before sending a request

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no <!-- please update src/**/CHANGELOG.md files -->
| BC breaks?    | no     <!-- see https://symfony.com/bc -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->
| Fixed tickets | n/a
| License       | MIT
| Doc PR        | n/a

Prevent throwing an error when calling getProfile before a request has been sent.

Commits
-------

9e6f4b2 [FrameworkBundle] Fix calling Client::getProfile() before sending a request
  • Loading branch information
fabpot committed Jun 26, 2019
2 parents 28b20b8 + 9e6f4b2 commit 7cc4cab
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Symfony/Bundle/FrameworkBundle/Client.php
Expand Up @@ -66,7 +66,7 @@ public function getKernel()
*/
public function getProfile()
{
if (!$this->kernel->getContainer()->has('profiler')) {
if (null === $this->response || !$this->kernel->getContainer()->has('profiler')) {
return false;
}

Expand Down
Expand Up @@ -28,9 +28,9 @@ public function testProfilerIsDisabled($insulate)

// enable the profiler for the next request
$client->enableProfiler();
$crawler = $client->request('GET', '/profiler');
$profile = $client->getProfile();
$this->assertInternalType('object', $profile);
$this->assertFalse($client->getProfile());
$client->request('GET', '/profiler');
$this->assertInternalType('object', $client->getProfile());

$client->request('GET', '/profiler');
$this->assertFalse($client->getProfile());
Expand Down

0 comments on commit 7cc4cab

Please sign in to comment.