Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

[Serializer] XmlEncoder doesn't ignore PI nodes while encoding#27926

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
dunglas merged 1 commit intosymfony:masterfrommaidmaid:serializer-pi
Aug 25, 2018

Conversation

@maidmaid
Copy link
Contributor

@maidmaidmaidmaid commentedJul 11, 2018
edited
Loading

QA
Branch?master
Bug fix?no
New feature?yes
BC breaks?no
Deprecations?no
Tests pass?no
Fixed tickets/
LicenseMIT
Doc PR/

It's sometimes important to get only the XML body without the processing instructions (like the<?xml version="1.0" ?> on the top of your XML doc). At the moment, it's possible to ignore them while decoding, but not while encoding.

$encoder =newXmlEncoder('response',null,$ignoredNodeTypes = [XML_PI_NODE]);echo$encoder->encode([],'xml');
Expected:<response/>Actual:<?xml version="1.0"?><response/>

So, a new$encoderIgnoredNodeTypes arg is added to the constructor which will be:

publicfunction __construct(string$rootNodeName ='response',int$loadOptions =null,array$decoderIgnoredNodeTypes =array(XML_PI_NODE,XML_COMMENT_NODE),array$encoderIgnoredNodeTypes =array())

@dunglas
Copy link
Member

We follow the robustness principle "Be conservative in what you send, be liberal in what you accept", so while it's ok to ignoreXML_PI_NODE by default when decoding, it must be generated by default when encoding.

I suggest to add a new constructor parameter:

publicfunction __construct(string$rootNodeName ='response',int$loadOptions =null,array$decoderIgnoredNodeTypes =array(XML_PI_NODE,XML_COMMENT_NODE),array$encoderIgnoredNodeTypes =array())

@nicolas-grekasnicolas-grekas added this to thenext milestoneJul 23, 2018
@maidmaidmaidmaidforce-pushed theserializer-pi branch 2 times, most recently fromd3d136d to9c182a2CompareAugust 6, 2018 22:53
@maidmaid
Copy link
ContributorAuthor

I followed your suggestion@dunglas, could you review ?

@nicolas-grekas
Copy link
Member

Is the "BC break" label still valid? If not can you please update the PR description? Rebase needed btw.

@maidmaid
Copy link
ContributorAuthor

@nicolas-grekas Done :)

@dunglas
Copy link
Member

Thank you@maidmaid.

@dunglasdunglas merged commit2223fcc intosymfony:masterAug 25, 2018
dunglas added a commit that referenced this pull requestAug 25, 2018
…encoding (maidmaid)This PR was merged into the 4.2-dev branch.Discussion----------[Serializer] XmlEncoder doesn't ignore PI nodes while encoding| Q             | A| ------------- | ---| Branch?       | master| Bug fix?      | no| New feature?  | yes| BC breaks?    | no| Deprecations? | no| Tests pass?   | no| Fixed tickets | /| License       | MIT| Doc PR        | /It's sometimes important to get only the XML body without the processing instructions (like the `<?xml version="1.0" ?>` on the top of your XML doc). At the moment, it's possible to ignore them while decoding, but not while encoding.```php$encoder = new XmlEncoder('response', null, $ignoredNodeTypes = [XML_PI_NODE]);echo $encoder->encode([], 'xml');``````Expected:<response/>Actual:<?xml version="1.0"?><response/>```So, a new `$encoderIgnoredNodeTypes` arg is added to the constructor which will be:```phppublic function __construct(string $rootNodeName = 'response', int $loadOptions = null, array $decoderIgnoredNodeTypes = array(XML_PI_NODE, XML_COMMENT_NODE), array $encoderIgnoredNodeTypes = array())```Commits-------2223fcc Allow to ignore PI while encoding
fabpot added a commit that referenced this pull requestAug 27, 2018
…redNodeTypes arg in XmlEncoder contrustor (maidmaid)This PR was merged into the 4.2-dev branch.Discussion----------[Serializer] Update changelog about the new $encoderIgnoredNodeTypes arg in XmlEncoder contrustor| Q             | A| ------------- | ---| Branch?       | master| Bug fix?      | no| New feature?  | no| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets |#27926| License       | MIT| Doc PR        | /Commits-------49f3bfc Update changelog
@maidmaidmaidmaid deleted the serializer-pi branchAugust 27, 2018 22:05
fabpot added a commit that referenced this pull requestAug 30, 2018
…ML encoding (maidmaid)This PR was merged into the 4.2-dev branch.Discussion----------[Serializer] Add support for ignoring comments while XML encoding| Q             | A| ------------- | ---| Branch?       | master| Bug fix?      | no| New feature?  | yes| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets | /| License       | MIT| Doc PR        | /In addition to#27926 which allowed to ignore XML processing instructions, this PR allows to ignore the XML comments while encoding.Commits-------8f8230a Add support for ignoring comments while XML encoding
@javiereguiluz
Copy link
Member

I've createdsymfony/symfony-docs#10286 to document this new feature. Please, don't forget to create a doc issue for every new feature.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@dunglasdunglasdunglas approved these changes

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

Assignees

No one assigned

Projects

None yet

Milestone

4.2

Development

Successfully merging this pull request may close these issues.

6 participants

@maidmaid@dunglas@nicolas-grekas@javiereguiluz@xabbuh@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp