Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[Serializer] Fix the XML comments encoding#28156
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
Uh oh!
There was an error while loading.Please reload this page.
Conversation
nicolas-grekas commentedAug 8, 2018
Which is the lowest branch where this applies? This should be the target branch. |
maidmaid commentedAug 8, 2018
2.8 is supposed to be the lowest branch, but before that, can you ensure me it's actually a bug and not a feature ? |
nicolas-grekas commentedAug 8, 2018
I cannot. Why do you think it's supposed to work this way? |
nicolas-grekas commentedAug 8, 2018
Actually not, which means this is a new feature, now a bug fix, isn't it? |
maidmaid commentedAug 8, 2018
Encoding I meant : encoding of XML comment wasn't handled before this PR. It's why we can see that as a new feature. On the other hand, the encoding and the decoding of a XML comment behave differently, it's why we also can see that as a bug. |
nicolas-grekas left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Oh, ok for a bug fix then on my side. Here are some more random comments :)
| * @throws NotEncodableValueException | ||
| */ | ||
| privatefunctionselectNodeType(\DOMNode$node,$val):bool | ||
| privatefunctionselectNodeType(\DOMNode$node,$val,$key =null):bool |
nicolas-grekasAug 15, 2018 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
why make it an optional argument? i.e.: shouldn't the call inside appendNode also pass the key?
otherside of the question: if the anwer is no, what about dealing with the#comment check in buildXml directly, adding} elseif ('#comment' === $key) { ...?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Right, dealing directly inbuildXml() makes more sense because it's here that we manage thespecial cases like@,# and now like#comment.
maidmaid commentedAug 15, 2018
As we said it's a bug fix, I rebased on 2.8. |
| returnfalse; | ||
| } | ||
| privatefunctionappendComment(\DOMNode$node,string$data):bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Final protected like the others?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Done ! (Could you explain to me the goal of a final protected method please ?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
goal of a final protected method
allowing child classes to call the method but not override it.
fabpot commentedAug 16, 2018
I don't see a big fix here but a new feature. |
maidmaid commentedAug 16, 2018 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@fabpot IMO, we should get an output equal to the input after decoding and then encoding it. Said differently, if this the condition below isn't respected, I think it's a bug : $encoded ===$encoder->encode($encoder->decode($encoded,$format),$format)) In this case, without this PR, the result it's like : '<a><!-- b --></a>' ==='<a><item key="#comment"> b </item></a>' |
09efffe to477df1dComparefabpot commentedAug 18, 2018
When the feature was added to the decoder, nobody thought about adding it to the decoder as well. That's sad we didn't think about this before. I still see it as a new feature (a missing one and a very welcome one for sure). |
maidmaid commentedAug 18, 2018
Ok@fabpot, let's see it as a (missing) new feature. I'll soon rebase on master. |
maidmaid commentedAug 18, 2018
Rebase done. |
fabpot commentedAug 18, 2018
Can you add a note in the CHANGELOG of the component? |
maidmaid commentedAug 19, 2018
Note added. |
fabpot commentedAug 19, 2018
Thank you@maidmaid. |
This PR was merged into the 4.2-dev branch.Discussion----------[Serializer] Fix the XML comments 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 | /When we decode a XML comment, we get `['#comment' => ' foo ']`. But when we encode this same content, the result is not the expected one.```php$encoder->encode(['#comment' => ' foo '], 'xml');``````Expected:<response> <!-- foo --></response>Actual:<response> <item key="#comment"> foo </item></response>```Commits-------d94a37f Allow to encode xml comments
Uh oh!
There was an error while loading.Please reload this page.
When we decode a XML comment, we get
['#comment' => ' foo ']. But when we encode this same content, the result is not the expected one.