8000 [VarDumper] VarCloner chokes on GMP numbers · Issue #25198 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[VarDumper] VarCloner chokes on GMP numbers #25198

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
fgm opened this issue Nov 28, 2017 · 2 comments
Closed

[VarDumper] VarCloner chokes on GMP numbers #25198

fgm opened this issue Nov 28, 2017 · 2 comments

Comments

@fgm
Copy link
Contributor
fgm commented Nov 28, 2017
Q A
Bug report? yes
Feature request? no
BC Break report? ?
RFC? no
Symfony version 3.3.13
PHP Version 7.1.11

When dumping data, the VarCloner incorrectly attempts to clone elements in the data tree in doClone() depending on their type, looping on this switch:

                // [...]
                switch (true) {
                    case empty($v):
                    case true === $v:
                    case \is_int($v):
                    case \is_float($v):
                        continue 2;
                // [...]

However, if $v is a GMP number, this switch throws a recoverable fatal error, because the switch evaluation tries to evaluate empty($v) but empty() does not accept a GMP argument:

// Minimal example in psysh:
$g = gmp_init('0');
=> GMP {#217}
empty($g);
// PHP Recoverable fatal error:  Object of class GMP could not be converted to boolean on line 1

The error needs to be caught to avoid crashing the dumper.

@nicolas-grekas
Copy link
Member
nicolas-grekas B2AD commented Nov 29, 2017

See #25209
Would you like to contribute a caster for GMP numbers btw?
Displaying just "GMP {#217}" is a bit terse, would be great to display the actual value.

nicolas-grekas added a commit that referenced this issue Nov 30, 2017
…(nicolas-grekas)

This PR was merged into the 3.3 branch.

Discussion
----------

[VarDumper] Dont use empty(), it chokes on eg GMP objects

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

Commits
-------

1b14173 [VarDumper] Dont use empty(), it chokes on eg GMP objects
@fgm
Copy link
Contributor Author
fgm commented Nov 30, 2017

You beat me to it 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants
0