Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[HttpKernel] DumpDataCollector: do not flush when a dumper is provided#26675

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
fabpot merged 1 commit intosymfony:2.7fromogizanagi:fix/2.7/dump_collector_flush_with_data_dumper
Mar 30, 2018
Merged

[HttpKernel] DumpDataCollector: do not flush when a dumper is provided#26675

fabpot merged 1 commit intosymfony:2.7fromogizanagi:fix/2.7/dump_collector_flush_with_data_dumper
Mar 30, 2018

Conversation

@ogizanagi
Copy link
Contributor

@ogizanagiogizanagi commentedMar 26, 2018
edited
Loading

QA
Branch?2.7
Bug fix?yes
New feature?no
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed ticketshttps://github.com/ogizanagi/symfony/blob/3db14045d41eecf78e3557c2d64f28fe27ed3a66/src/Symfony/Component/HttpKernel/DataCollector/DumpDataCollector.php#L208-L209
LicenseMIT
Doc PRN/A

This explainsthe workaround I initially used in the server dumper PR original code.

I might be wrong on the intent, but as soon as a dumper is provided (e.g by settingdebug.dump_destination: php://stderr), I think there is no need to set theDumpDataCollector::$isCollected flag tofalse as we explicitly ask for the dump to be output directly somewhere. So ne need to output again on__destruct.

Spotted by running tests on thesymfony/demo with the server dumper enabled: dumps were output twice. Once on the server, once at the end of the tests.

But this can be easily seen as well by usingdebug.dump_destination: php://stderr ontest env:

diff --git a/src/Controller/BlogController.php b/src/Controller/BlogController.phpindex e3e30aa..bf9744e 100644--- a/src/Controller/BlogController.php+++ b/src/Controller/BlogController.php@@ -50,6 +50,7 @@ class BlogController extends AbstractController      */     public function index(int $page, string $_format, PostRepository $posts): Response     {+        dump(get_class($posts));         $latestPosts = $posts->findLatest($page);          // Every template name also has two extensions that specify the format and

Before

vendor/bin/simple-phpunit --filter=BlogControllerTest::testIndexPHPUnit 6.5.7 by Sebastian Bergmann and contributors.Testing Project Test SuiteBlogController.php on line 53:"App\Repository\PostRepository".                                                                   1 / 1 (100%)Time: 3.34 seconds, Memory: 44.25MBOK (1 test, 1 assertion)BlogController.php on line 53:"App\Repository\PostRepository"

After

vendor/bin/simple-phpunit --filter=BlogControllerTest::testIndexPHPUnit 6.5.7 by Sebastian Bergmann and contributors.Testing Project Test SuiteBlogController.php on line 53:"App\Repository\PostRepository".                                                                   1 / 1 (100%)Time: 731 ms, Memory: 28.00MBOK (1 test, 1 assertion)


if ($this->dumper) {
$this->doDump($data,$name,$file,$line);
$this->isCollected =true;
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Instead we could tweakhttps://github.com/symfony/symfony/pull/26675/files#diff-b043f95afd7daa1be0bdd864620c510dR70 to check if$this->dumper is set. But I find it more expressive as is. Let me know.

Choose a reason for hiding this comment

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

if we can achieve the same without mutating any state, that may be better?

Choose a reason for hiding this comment

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

if we can achieve the same without mutating any state, that may be better?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Alright

@nicolas-grekasnicolas-grekas added this to the4.1 milestoneMar 27, 2018
@chalasrchalasr modified the milestones:4.1,2.7Mar 30, 2018
@fabpot
Copy link
Member

Thank you@ogizanagi.

@fabpotfabpot merged commit11a0392 intosymfony:2.7Mar 30, 2018
fabpot added a commit that referenced this pull requestMar 30, 2018
… is provided (ogizanagi)This PR was merged into the 2.7 branch.Discussion----------[HttpKernel] DumpDataCollector: do not flush when a dumper is provided| Q             | A| ------------- | ---| Branch?       | 2.7 <!-- see below -->| Bug fix?      | yes| New feature?  | no <!-- don't forget to update src/**/CHANGELOG.md files -->| BC breaks?    | no     <!-- seehttps://symfony.com/bc -->| Deprecations? | no <!-- don't forget to update UPGRADE-*.md and src/**/CHANGELOG.md files -->| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->| Fixed tickets |https://github.com/ogizanagi/symfony/blob/3db14045d41eecf78e3557c2d64f28fe27ed3a66/src/Symfony/Component/HttpKernel/DataCollector/DumpDataCollector.php#L208-L209   <!-- #-prefixed issue number(s), if any -->| License       | MIT| Doc PR        | N/AThis explains [the workaround I initially used](https://github.com/ogizanagi/symfony/blob/3db14045d41eecf78e3557c2d64f28fe27ed3a66/src/Symfony/Component/HttpKernel/DataCollector/DumpDataCollector.php#L208-L209) in the server dumper PR original code.I might be wrong on the intent, but as soon as a dumper is provided (e.g by setting  `debug.dump_destination: php://stderr`), I think there is no need to set the `DumpDataCollector::$isCollected` flag to `false` as we explicitly ask for the dump to be output directly somewhere. So ne need to output again on `__destruct`.Spotted by running tests on the `symfony/demo` with the server dumper enabled: dumps were output twice. Once on the server, once at the end of the tests.But this can be easily seen as well by using `debug.dump_destination: php://stderr` on `test` env:```diffdiff --git a/src/Controller/BlogController.php b/src/Controller/BlogController.phpindex e3e30aa..bf9744e 100644--- a/src/Controller/BlogController.php+++ b/src/Controller/BlogController.php@@ -50,6 +50,7 @@ class BlogController extends AbstractController      */     public function index(int $page, string $_format, PostRepository $posts): Response     {+        dump(get_class($posts));         $latestPosts = $posts->findLatest($page);         // Every template name also has two extensions that specify the format and```### Before```shvendor/bin/simple-phpunit --filter=BlogControllerTest::testIndexPHPUnit 6.5.7 by Sebastian Bergmann and contributors.Testing Project Test SuiteBlogController.php on line 53:"App\Repository\PostRepository".                                                                   1 / 1 (100%)Time: 3.34 seconds, Memory: 44.25MBOK (1 test, 1 assertion)BlogController.php on line 53:"App\Repository\PostRepository"```### After```shvendor/bin/simple-phpunit --filter=BlogControllerTest::testIndexPHPUnit 6.5.7 by Sebastian Bergmann and contributors.Testing Project Test SuiteBlogController.php on line 53:"App\Repository\PostRepository".                                                                   1 / 1 (100%)Time: 731 ms, Memory: 28.00MBOK (1 test, 1 assertion)```Commits-------11a0392 [HttpKernel] DumpDataCollector: do not flush when a dumper is provided
@ogizanagiogizanagi deleted the fix/2.7/dump_collector_flush_with_data_dumper branchMarch 30, 2018 08:38
This was referencedApr 2, 2018
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@fabpotfabpotfabpot approved these changes

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

Assignees

No one assigned

Projects

None yet

Milestone

2.7

Development

Successfully merging this pull request may close these issues.

5 participants

@ogizanagi@fabpot@nicolas-grekas@chalasr@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp