8000 [VarDumper] Fix error with uninitialized XMLReader by villfa · Pull Request #43413 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[VarDumper] Fix error with uninitialized XMLReader #43413

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
Oct 14, 2021
Merged

[VarDumper] Fix error with uninitialized XMLReader #43413

merged 1 commit into from
Oct 14, 2021

Conversation

villfa
Copy link
Contributor
@villfa villfa commented Oct 12, 2021
Q A
Branch? 4.4
Bug fix? yes
New feature? no
Deprecations? no
Tickets Fix #42581
License MIT
Doc PR n/a

When XMLReader is not initialized, getParserProperty() throws an error (or emits a warning, depending on the PHP version).
Now the error is caught and the properties are set to false.

@carsonbot
Copy link

Hey!

I think @fancyweb has recently worked with this code. Maybe they can help review this?

Cheers!

Carsonbot

@villfa
Copy link
Contributor Author
villfa commented Oct 13, 2021

Hi @fabpot,
The error from fabbot.io is a false positive, so I'm wondering if the code of this bot is open in order to fix it.
Or maybe it relies on open tools?

'VALIDATE' => @$reader->getParserProperty(\XMLReader::VALIDATE),
'SUBST_ENTITIES' => @$reader->getParserProperty(\XMLReader::SUBST_ENTITIES),
];
} catch (Error $e) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
} catch (Error $e) {
} catch (\ValueError $e) {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've used Error instead of ValueError on purpose because of this fix in PHP: php/php-src@53f8921

Copy link
Member
@derrabus derrabus Oct 13, 2021

Choose a reason for hiding this comment

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

That makes total sense. I can confirm that an Error is triggered on the latest PHP snapshot.

That makes me wonder: Is there a better way to detect an uninitialized XMLReader than to catch a generic Error?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've double-checked the XMLReader documentation and source code, and I couldn't find another way to check if an instance is not yet initialized :(

@derrabus
Copy link
Member

Thank you for your PR, @villfa. The open source tool that fabbot relies on is PHP CS Fixer. Since the failure is a false positive as you already discovered, you can simply ignore it. 🙂

@fabpot
Copy link
Member
fabpot commented Oct 14, 2021

Thank you @villfa.

@fabpot fabpot merged commit 049e641 into symfony:4.4 Oct 14, 2021
@villfa villfa deleted the fix/42581 branch October 14, 2021 07:54
This was referenced Oct 29, 2021
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
0