10000 The function dd() is not working in laravel · Issue #39394 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

The function dd() is not working in laravel #39394

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
overMiracle opened this issue Dec 9, 2020 · 18 comments
Closed

The function dd() is not working in laravel #39394

overMiracle opened this issue Dec 9, 2020 · 18 comments

Comments

@overMiracle
Copy link

Symfony version(s) affected: symfony/var-dumper:5.2
PHP version:8.0
Laravel version:8.17.2
Description

When I print the collection use the dd function, I cannot see the nested content inside the collection,like the following,
Illuminate\Database\Eloquent\Collection {#992 #items: array:9 [] }
i cant see any items,the previous version can be expanded to view specific items

@overMiracle overMiracle added the Bug label Dec 9, 2020
@overMiracle overMiracle changed the title The function dd() is not working The function dd() is not working in laravel Dec 9, 2020
@xabbuh
Copy link
Member
xabbuh commented Dec 9, 2020

Can you create a small example application that allows to reproduce your issue?

@overMiracle
Copy link
Author

82325B631CF65E09B34539CC1B0D9253

Like the above picture,the nested element is empty!Why???

@ro0NL
Copy link
Contributor
ro0NL commented Dec 9, 2020

@buffary we need to understand what happens technically first, before we can answer the why.

So any insights what's causing length=9 but [] for rendering is welcome.

We need to isolate the problem. Maybe it can be reproduced as simple as dd(new Collection(range(1,9))) but that's up to you to confirm at first.

A piece of code reproducing the output from the screenshot above allows others to gain such insights as well.

@zoriax
Copy link
zoriax commented Dec 14, 2020

Hello,

Same issue here, it apperas on axios response :

dump(['test0' => ['test1' => 'test1', 'test2' => 'test2']]);

It returns

image

If you use dd() in for exemple web.php Laravel page, it works.

Thanks

@NeutronSelector
Copy link

Hello,

I have the same problem.
I do the following line in AppServiceProvider.php

dd(config('applications.forms.app_name.beneficiary_forms'));

image

But if the same line is called through an axios call

image

And in preview of response in network tab of browser is the same result

image

In the response tab the HTML code seems to be complete
image

Thanks

@NeutronSelector
Copy link

P.S.
It works with laravel 8.12.1, upgrading to version 8.18.1 it no longer works. No code change in the application.

@derrabus
Copy link
Member

All right, please help a Laravel noob like me to reproduce the problem: Please create a small application that I can run to reproduce the problem. Share that application as a GitHub repo and link it in this thread. Thanks!

@NeutronSelector
Copy link

Hello,

Here is an empty app with the bug.
https://github.com/ciad/debug_dd

On the home page at the top there is a dump() of an array, everything works.

Then next to the Laravel logo I put a horrible button "Axios Request"
Click on it then go to the Network and Previem tab of Chrome and the dump() is bugged (not unfoldable).

For info dump() and dd() behave the same way.

The code for these two debugs can be found in HomeController.php.
The axios request in a script at the bottom of the welcome.blade.php view.

I hope I was chaired enough this time ...

Thank you.

@bpuig
Copy link
bpuig commented Dec 16, 2020

Changes made in this commit changed the behaviour in 5.2.0:

symfony/var-dumper@4b5ca00

This "improve" of the "rendering" messed up response inspectors.

@nicolas-grekas
Copy link
Member

Thanks for the details, the related PR is #35959.
This looks like a pure JavaScript issue then! Could anyone try to figure out what's wrong there? Is there any JavaScript error in the dev tools of the browser?
Please submit a PR if you find the cause.

@rodrigopedra
Copy link

Hi @derrabus

I tracked down the changed behavior to this commit: symfony/var-dumper@4b5ca00

Reverting it brings the old behavior back.

Note it only happens when previewing the results of calling dd(...) on the network tab, I tested in both Chrome and Firefox.

It doesn't need to be an AJAX call, you can preview a regular page, in the regular browser nested properties will be interactive/collapsible, while if previewing the HTML document on the developer tools' network tab it won't be interactive/expandable.

Previous behavior before the commit above was to have all properties expanded when previewing on the network tab.

To reproduce it you don't need to use Laravel. You can reproduce this with the following steps:

mkdir test
cd test
composer init
composer require symfony/var-dumper
echo "<?php require __DIR__ . '/vendor/autoload.php'; dd(['foo' => [1,2,3]]);" > index.php
php -S localhost:8000
  • Navigate to http://localhost:8000
  • Output on browser should be as expected (expandable/collapsible)
  • Open developer tools (I tested on Chrome and Firefox)
  • Select the Network tab
  • Click the HTML response
  • The preview panel will show the response collapsed

My guess is that the commit above changed the output from expanded by default to collapsed by default. And as the network tab's preview pane doesn't run JavaScript the results cannot be expanded.

Users might be relying on the results to be expanded to debug AJAX calls.

Hope this helps.

@rodrigopedra
Copy link

Hi @nicolas-grekas and @bpuig

I was typing my response before seeing yours.

Unfortunately I am not familiar with symfony's codebase/code-style to send a PR.

Hope it can help debugging it.

@nicolas-grekas
Copy link
Member

The codebase here is very simple here: a single file is used to generate all the HTML & JavaScript.
See #35959

@rodrigopedra
Copy link

@nicolas-grekas

I just sent PR #39523 to revert PR #35959

@NeutronSelector
Copy link

@rodrigopedra Indeed I had not thought of looking at the network tab in a page debug without AJAX call (since it is displayed directly on the web page)

8000

@nicolas-grekas
Copy link
Member

Please give #39525 a try and confirm it fixes the issue if you can.

@rodrigopedra
Copy link

Hi @nicolas-grekas I tried #39525 and it is working as expected regarding the network tab.

I guess, as the JavaScript code is the first thing rendered, it will also prevent any flickering reported by issue #35800.

Thanks!

@NeutronSelector
Copy link

Hello,

@nicolas-grekas #39525 works for me !

Thanks !

nicolas-grekas added a commit that referenced this issue Dec 17, 2020
… (nicolas-grekas)

This PR was merged into the 5.2 branch.

Discussion
----------

[VarDumper] dont hide any nodes until JS is proven to work

| Q             | A
| ------------- | ---
| Branch?       | 5.2
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #39394
| License       | MIT
| Doc PR        | -

Replaces #39523

Commits
-------

42ad1ec [VarDumper] dont hide any nodes until JS is proven to work
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants
0