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

Skip to content

[VarDumper] Output the location of calls to dump() #31446

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 1 commit into from
Sep 28, 2019

Conversation

ktherage
Copy link
Contributor

@ktherage ktherage commented May 9, 2019

Q A
Branch? 4.4
Bug fix? yes
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? not tested yet
Fixed tickets #30830
License MIT
Doc PR

see #30830

@nicolas-grekas
Copy link
Member

nicolas-grekas commented May 21, 2019

The implementation relies on a statefull service. This should be avoided.
If we need dumping some context, it should be added to the Data object to me.
Then, dumpers could read it and do things appropriately.
See also SourceContextProvider which has more intensive logic for extracting the stack trace.

@ktherage
Copy link
Contributor Author

@nicolas-grekas Thank you for the feed back. I've changed the implementation.

Do you have an idea on how can i insulate this new feature and set her only for CliDumper?

Because currently, without forcing file and line to null in getDump method of VarDumperTestTrait it has impact on all other tests and so maybe on functionnalities.

@Simperfit
Copy link
Contributor

@ktherage can we move forward on this ;) ?

@ktherage
Copy link
Contributor Author

@Simperfit I'm stuck on unit tests. I this they are to much nested each other. Testing cli dumper makes HtmlDumper, ServerDumper and all the caster crashed.

@ktherage ktherage force-pushed the poc-var-dump branch 2 times, most recently from 57c55fd to a5f8258 Compare July 1, 2019 13:04
@ktherage
Copy link
Contributor Author

ktherage commented Jul 1, 2019

@Simperfit @nicolas-grekas, I did some work on that, tests are finally green.
Could you, please, take a sometime to check those changes?

Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

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

I'm sorry but I'm not comfortable at all with the way this is implemented. This feels like breaking all semantics to fit the target.

  • Data::dump() is about the represented structure. It cannot snif the context.
  • CliDumper is about dumping the same structure, not the context.

I think ServerDumper does it properly:

  • the context is collected completly separately, in a flexible way
  • the context is dumped separately

Here is a proposal: add a ContextualizedDumper that collects+dumps contexts and dumps using a decorated dumper - very alike ServerDumper. Writting to the output should be done using the decorated dumper too (unlike ServerDumpCommand, which write to Console i/o)

I hope this helps.

@ktherage
Copy link
Contributor Author

ktherage commented Jul 12, 2019

@nicolas-grekas I've applied your recommendations (hoping i've not misread them).
Can you review those changes please ?

@nicolas-grekas nicolas-grekas changed the title POC adding of href link to the dump call location [VarDumper] Output the location of calls to dump() Jul 15, 2019
@nicolas-grekas nicolas-grekas changed the base branch from master to 4.4 July 15, 2019 17:36
@nicolas-grekas nicolas-grekas force-pushed the poc-var-dump branch 2 times, most recently from c705ebc to dace4a0 Compare July 16, 2019 16:38
@nicolas-grekas
Copy link
Member

I push-forced on your fork to rebase+target 4.4, and do some changes.
Can you please try if that works for you?
Also, I think this doesn't work when dump is called from inside console commands.
Can you also check that?

@ktherage
Copy link
Contributor Author

I push-forced on your fork to rebase+target 4.4, and do some changes.
Can you please try if that works for you?
Also, I think this doesn't work when dump is called from inside console commands.
Can you also check that?

@nicolas-grekas i've adapter unit test according to your changes and i've added one test for console command. Can you check them and tell me if they are good for you?

@ktherage ktherage force-pushed the poc-var-dump branch 2 times, most recently from 5e8f3f0 to 863727e Compare July 19, 2019 09:04
@ktherage
Copy link
Contributor Author

As we talked together, i've adapted tests to a smaller sample an removed the fix i made on CliDumper for tests.

I've also tried to call dump in a command of a website-skeleton and, as you pre-minded it, it does not worked but i don't know why (see the GIF bellow).

Peek 18-07-2019 17-03

@nicolas-grekas
Copy link
Member

nicolas-grekas commented Jul 30, 2019

@ktherage the reason is that we wire a service as a dumper. Look for cli_dumper/html_dumper I think in the code base

@ktherage
Copy link
Contributor Author

ktherage commented Aug 5, 2019

@ktherage the reason is that we wire a service as a dumper. Look for cli_dumper/html_dumper I think in the code base

@nicolas-grekas Yes, here it is.
Do you mean that i shall add a service definition like that one below :

        <service id="var_dumper.contextualized_cli_dumper" class="Symfony\Component\VarDumper\Dumper\ContextualizedDumper">
            <argument type="service" id="var_dumper.cli_dumper" />
            <argument type="collection">
                <argument type="service" key="source">
                    <service class="Symfony\Component\VarDumper\Dumper\ContextProvider\SourceContextProvider">
                        <argument>%kernel.charset%</argument>
                        <argument type="string">%kernel.project_dir%</argument>
                        <argument type="service" id="debug.file_link_formatter" on-invalid="null" />
                    </service>
                </argument>
            </argument>
        </service>

and use this new service in the debug bundle in place of the var_dumper.cli_dumper service ?

@ktherage ktherage force-pushed the poc-var-dump branch 3 times, most recently from 0914988 to 282eb4b Compare September 10, 2019 15:14
@ktherage
Copy link
Contributor Author

ktherage commented Sep 10, 2019

@nicolas-grekas I've worked on that and fixed the error for commands (see bellow).

I also tried to fix the tests. But for me the CI behave strangely (depending on the php version).

Peek 10-09-2019 15-05

@nicolas-grekas nicolas-grekas force-pushed the poc-var-dump branch 4 times, most recently from aec00cb to d05003d Compare September 28, 2019 16:06
Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

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

(I tested locally and fixed tests)

@nicolas-grekas
Copy link
Member

Thank you @ktherage.

nicolas-grekas added a commit that referenced this pull request Sep 28, 2019
…herage)

This PR was merged into the 4.4 branch.

Discussion
----------

[VarDumper] Output the location of calls to dump()

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | not tested yet
| Fixed tickets | #30830
| License       | MIT
| Doc PR        |

see #30830

Commits
-------

f0a59d3 [VarDumper] Output the location of calls to dump()
@nicolas-grekas nicolas-grekas merged commit f0a59d3 into symfony:4.4 Sep 28, 2019
@nicolas-grekas nicolas-grekas modified the milestones: next, 4.4 Oct 27, 2019
This was referenced Nov 12, 2019
@alimranahmed
Copy link

Peek 10-09-2019 15-05

It doesn't work this way in browser.

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.

5 participants