Skip to content
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

[Config] extracted the xml parsing from XmlUtils::loadFile into XmlUtils::parse #23485

Closed
wants to merge 12 commits into from

Conversation

Basster
Copy link
Contributor

@Basster Basster commented Jul 12, 2017

Q A
Branch? 3.4
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
License MIT

I needed the xml parsing for an XML string generated in memory, so I extracted the actual parsing from XmlUtils::loadFile into XmlUtils::load.

Re-opened after I messed some things up in #23482

CONTRIBUTORS.md Outdated
@@ -1723,3 +1723,4 @@ Symfony is the result of the work of many people who made the code better
- Thomas BERTRAND (sevrahk)
- Matej Žilák (teo_sk)
- Vladislav Vlastovskiy (vlastv)
- Ole Rößner (basster)
Copy link
Contributor

Choose a reason for hiding this comment

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

As far as I know, this file is auto-generated, so doesn't need to be manually modified

@nicolas-grekas nicolas-grekas added this to the 3.4 milestone Jul 13, 2017

try {
return static::parse($content, $schemaOrCallable);
} catch (\InvalidArgumentException $ex) {
Copy link
Member

Choose a reason for hiding this comment

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

the convention is to name this var $e

try {
return static::parse($content, $schemaOrCallable);
} catch (\InvalidArgumentException $ex) {
throw new \InvalidArgumentException(
Copy link
Member

@nicolas-grekas nicolas-grekas Jul 13, 2017

Choose a reason for hiding this comment

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

I propose this instead:

if ('The XML is not valid.' !== $ex->getMessage()) {
    throw $e;
}
throw new \InvalidArgumentException(sprintf('The XML file "%s" is not valid.', $file), 0, $e->getPrevious());

@Basster
Copy link
Contributor Author

Basster commented Jul 16, 2017

@nicolas-grekas Is there any way, besides pushing changes, to retrigger the builds? I don't see how the failing test is related to my changes.

try {
return static::parse($content, $schemaOrCallable);
} catch (\InvalidArgumentException $e) {
if ('The XML is not valid.' !== $e->getMessage()) {
Copy link
Member

Choose a reason for hiding this comment

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

Logic sounds very fragile to me. Can we instead add a code to the exception and check the code here?

Copy link
Contributor Author

@Basster Basster Jul 17, 2017

Choose a reason for hiding this comment

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

sure, sounds comprehensible. @fabpot any preferences or guidelines for internal exception codes?

Copy link
Member

Choose a reason for hiding this comment

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

No guidelines. I think we don't have any other examples in the framework. Another option would be to create a dedicated exception class.

Copy link
Contributor Author

@Basster Basster Jul 17, 2017

Choose a reason for hiding this comment

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

Sounds even cleaner to me, but wouldn't that result in a BC break?

Copy link
Member

Choose a reason for hiding this comment

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

a dedicated exception class would have my preference

@Basster
Copy link
Contributor Author

Basster commented Aug 24, 2017

friendly ping

@nicolas-grekas
Copy link
Member

@Basster can you rebase (and squash meanwhile if you want) please so that the merge commit disappears?

@Basster
Copy link
Contributor Author

Basster commented Aug 24, 2017

Moderators earlier asked you to "squash" your commits. This means you will convert many commits to one commit. This is no longer necessary today, because Symfony project uses a proprietary tool which automatically squashes all commits before merging.

From https://symfony.com/doc/current/contributing/code/patches.html, should I do so, anyways?

@chalasr
Copy link
Member

chalasr commented Sep 4, 2017

Not if you don't want :)

(and squash meanwhile if you want)

But rebasing is needed as there is a conflict.

@ogizanagi ogizanagi self-requested a review September 5, 2017 20:19
@nicolas-grekas
Copy link
Member

@Basster would you have some time to rebase before the end of the week?

@Basster
Copy link
Contributor Author

Basster commented Sep 26, 2017

@nicolas-grekas done (hopefully correct)

@nicolas-grekas
Copy link
Member

ping @symfony/deciders

@ogizanagi
Copy link
Contributor

Thank you @Basster.

ogizanagi added a commit that referenced this pull request Sep 26, 2017
…File into XmlUtils::parse (Basster)

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

Discussion
----------

[Config] extracted the xml parsing from XmlUtils::loadFile into XmlUtils::parse

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

I needed the xml parsing for an XML string generated in memory, so I extracted the actual parsing from XmlUtils::loadFile into XmlUtils::load.

Re-opened after I messed some things up in #23482

Commits
-------

7473981 [Config] extracted the xml parsing from XmlUtils::loadFile into XmlUtils::parse
@ogizanagi ogizanagi closed this Sep 26, 2017
ogizanagi added a commit that referenced this pull request Sep 26, 2017
fabpot added a commit that referenced this pull request Sep 26, 2017
* 3.4:
  Passing the newly generated security token to the event during user switching.
  Fix changelog and minor tweak for #23485
  [Config] extracted the xml parsing from XmlUtils::loadFile into XmlUtils::parse
  [Security][SecurityBundle] Deprecate the HTTP digest auth
  add ability to configure catching exceptions
  Extract method refactoring for ResourceCheckerConfigCache
This was referenced Oct 18, 2017
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.

8 participants