Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Serializer] Fix issue related to handling namespace attributes in the XmlEncoder class #52401

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
wants to merge 2 commits into from

Conversation

Youngemmy5956
Copy link

@Youngemmy5956 Youngemmy5956 commented Nov 1, 2023

Q A
Branch? 6.4
Bug fix? yes
New feature? no
Deprecations? no
Issues --
License MIT

The XmlEncoder in Symfony does not parse the namespace for a node without children, resulting in invalid XML when encoding. The suggested solution is to modify the XmlEncoder::parseXmlAttributes method to fetch the namespace from the node if it has one.

 fix the issue related to handling namespace attributes in the XmlEncoder class.
@carsonbot
Copy link

Hey!

Thanks for your PR. You are targeting branch "6.4" but it seems your PR description refers to branch "6.4 for features / 5.4 or 6.3 for bug fixes".
Could you update the PR description or change target branch? This helps core maintainers a lot.

Cheers!

Carsonbot

@welcoMattic welcoMattic changed the title Update XmlEncoder.php [Serializer] Update XmlEncoder.php Nov 1, 2023
@xabbuh
Copy link
Member

xabbuh commented Nov 1, 2023

Can you clarify what "the issue" issue is that you are trying to fix here please? Please also add a test that ensures we don't break the fixed behaviour in the future.

@carsonbot carsonbot changed the title [Serializer] Update XmlEncoder.php Update XmlEncoder.php Nov 1, 2023
@OskarStark OskarStark changed the title Update XmlEncoder.php Fix issue related to handling namespace attributes in the XmlEncoder class Nov 1, 2023
@Youngemmy5956 Youngemmy5956 reopened this Nov 2, 2023
@Youngemmy5956
Copy link
Author

Youngemmy5956 commented Nov 2, 2023

Can you clarify what "the issue" issue is that you are trying to fix here please? Please also add a test that ensures we don't break the fixed behaviour in the future.

The XmlEncoder in Symfony does not parse the namespace for a node without children, resulting in invalid XML when encoding. The suggested solution is to modify the XmlEncoder::parseXmlAttributes method to fetch the namespace from the node if it has one.

@carsonbot carsonbot changed the title Fix issue related to handling namespace attributes in the XmlEncoder class [Serializer] Fix issue related to handling namespace attributes in the XmlEncoder class Nov 3, 2023
added the test for xml namespace
@OskarStark
Copy link
Contributor

OskarStark commented Nov 3, 2023

I cherry picked the test from

And added the explanation to the PR header

@symfony symfony deleted a comment from Youngemmy5956 Nov 3, 2023
@OskarStark
Copy link
Contributor

Your test case is failing, can you please check? Thanks

There was 1 failure:

1) Symfony\Component\Serializer\Tests\Encoder\XmlEncoderTest::testParseXmlAttributesWithNamespace
Failed asserting that two arrays are equal.
--- Expected
+++ Actual
@@ @@
 Array (
-    '@xmlns:ns' => 'http://example.com/'
     '@ns:attribute' => 'value'
+    '#' => ''
 )

/home/runner/work/symfony/symfony/src/Symfony/Component/Serializer/Tests/Encoder/XmlEncoderTest.php:412

@nicolas-grekas nicolas-grekas added this to the 6.4 milestone Nov 15, 2023
@mtarld
Copy link
Contributor

mtarld commented Nov 20, 2023

Hey @Youngemmy5956, I didn't notice your PR and came up with the following: #52589.

Does it solve your issue?

@fabpot
Copy link
Member

fabpot commented Nov 23, 2023

Closing in favor of #52589

@fabpot fabpot closed this Nov 23, 2023
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.

7 participants