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

[Serializer] paralell XMLEncoder::encode can cause "Wrong Document Error" #37354

Closed
connorhu opened this issue Jun 19, 2020 · 4 comments · Fixed by #38534
Closed

[Serializer] paralell XMLEncoder::encode can cause "Wrong Document Error" #37354

connorhu opened this issue Jun 19, 2020 · 4 comments · Fixed by #38534

Comments

@connorhu
Copy link
Contributor

Symfony version(s) affected: 5.0

Description
If you start an XMLEncode::encode process in the middle of a normalization (you need to create an base64 encoded XML sub document), cause an "Wrong Document Error" DomDocument exception at:

$parentNode->appendChild($node);

Here is the call stack:

How to reproduce
Create an XML with an base64 encoded xml subcontent:

<?xml version="1.0"?>
<node>...base64encoded xml...</node>

xml to base64 encode:

<?xml version="1.0"?>
<node2>test</node2>

Possible Solution
DOMDocument of XMLEncoder should stackable.

Additional context
I will post repo, test and PR later.

@connorhu connorhu added the Bug label Jun 19, 2020
@connorhu connorhu changed the title [Serializer] running encode right in the middle a normalization process cause "Wrong Document Error" [Serializer] paralell XMLEncoder::encode can cause "Wrong Document Error" Jun 19, 2020
@connorhu
Copy link
Contributor Author

@carsonbot
Copy link

Hey, thanks for your report!
There has not been a lot of activity here for a while. Is this bug still relevant? Have you managed to find a workaround?

@carsonbot
Copy link

Friendly reminder that this issue exists. If I don't hear anything I'll close this.

@carsonbot
Copy link

Hey,

I didn't hear anything so I'm going to close it. Feel free to comment if this is still relevant, I can always reopen!

nicolas-grekas added a commit that referenced this issue Jan 31, 2022
…norhu)

This PR was merged into the 4.4 branch.

Discussion
----------

[Serializer] make XmlEncoder stateless thus reentrant

| Q             | A
| ------------- | ---
| Branch?       | 5.x
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #37354
| License       | MIT

Changing dom property of XmlEncoder to stackable. It fixes a DOMException "Wrong document error". When you calling XmlEncoder->encode() in parallel createDomDocument replaces the DomDocument object.
Test code:
https://github.com/connorhu/symfony-serializer/blob/master/test.php

Commits
-------

693f9ab [Serializer] make XmlEncoder stateless thus reentrant
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants