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

Appearance settings

[3.4] - Bug Fix - Fix global dump function return value for PHP7 #28491

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

Conversation

patrickcarlohickman
Copy link
Contributor

Q A
Branch? 4.0
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets
License MIT
Doc PR

In 3.4, the global dump() helper function in the VarDumper component was updated to return the arguments passed in to it. However, in 4.0, the way the variables are dumped was updated, and it introduced a bug in PHP7 in the return value of the function.

With the update made in 4.0, the variable used in the foreach loop overwrites the value passed in by the first argument. In PHP5, this is okay. In PHP7, even though the argument is passed by value, the value returned by func_get_args() is affected by changes to the arguments inside the function. This is a change from PHP5.

From the documentation for func_get_args():

If the arguments are passed by reference, any changes to the arguments will be reflected in the values returned by this function. As of PHP 7 the current values will also be returned if the arguments are passed by value.

This PR simply changes the name of the variable used in the foreach loop. It also adds a test file to test the return value of the global dump() function.

This is my first contribution to Symfony, so please let me know if the issue should be resolved in a different manner, or if the test should be modified in any way.

Thanks,
Patrick

Copy link
Contributor

@ro0NL ro0NL left a comment

Choose a reason for hiding this comment

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

@nicolas-grekas
Copy link
Member

Nice catch. I'd suggest to name the new var just $v as we do in other places.
This issue also exists on branch 3.4, so this is where this should be merged.
(you can rebase+retarget if you want and know how to do it.)

@patrickcarlohickman
Copy link
Contributor Author

@nicolas-grekas You're absolutely correct. Silly oversight on my part. I'll update and retarget tonight. I'll change the var to $v, as well. Thanks!

@patrickcarlohickman patrickcarlohickman deleted the fix-dump-helper-return branch September 18, 2018 03:36
@patrickcarlohickman patrickcarlohickman changed the base branch from 4.0 to 3.4 September 18, 2018 03:38
@patrickcarlohickman patrickcarlohickman changed the title [4.0] - Bug Fix - Fix global dump function return value for PHP7 [3.4] - Bug Fix - Fix global dump function return value for PHP7 Sep 18, 2018
@patrickcarlohickman
Copy link
Contributor Author

Well, GitHub did not like what I did and closed this PR. I have created a new PR (#28497), targeted at 3.4, with the mentioned variable change. I apologize for the extra PR. 😒

nicolas-grekas added a commit that referenced this pull request Sep 18, 2018
… (patrickcarlohickman)

This PR was squashed before being merged into the 3.4 branch (closes #28497).

Discussion
----------

[VarDumper] Fix global dump function return value for PHP7

Retarget of PR #28491. Reposting description below, with relevant updates.

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets |
| License       | MIT
| Doc PR        |

In 3.4, the global `dump()` helper function in the VarDumper component was updated to return the arguments passed in to it. However, due to reusing the argument variable in the function, this introduces a bug in PHP7 in the return value of the function.

The variable used in the `foreach` loop overwrites the value passed in by the first argument. In PHP5, this is okay. In PHP7, even though the argument is passed by value, the value returned by `func_get_args()` is affected by changes to the arguments inside the function. This is a change from PHP5.

From the documentation for [`func_get_args()`](http://php.net/manual/en/function.func-get-args.php):

> If the arguments are passed by reference, any changes to the arguments will be reflected in the values returned by this function. As of PHP 7 the current values will also be returned if the arguments are passed by value.

This PR simply changes the name of the variable used in the `foreach` loop. It also adds a test file to test the return value of the global `dump()` function.

This is my first contribution to Symfony, so please let me know if the issue should be resolved in a different manner, or if the test should be modified in any way.

Thanks,
Patrick

Commits
-------

0def211 [VarDumper] Fix global dump function return value for PHP7
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.

4 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.