-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
DOMDocument schemaValidate error migrating to PHP 8.2 #11117
Comments
Hi! 👋 After reading this, I think I should have added an -if (! @$document->schemaValidate(__DIR__ . '/../../../../../doctrine-mapping.xsd')) {
+if (! $document->schemaValidate(__DIR__ . '/../../../../../doctrine-mapping.xsd')) { After that, you should get a detailed error message. |
I had the same problem after updating PHP 8.1 to 8.1.26. With this PHP update, the libxml2 library was also updated to version 2.12.2. After downgrading the libxml2 library to version 2.11.5, the problem has gone. I suppose two scenarios:
|
Hi @greg0ire . If I add the Hi @mleko64 . I think you are right. A colleague of mine doesn't experience the same problem as I do. It appears we have different libxml versions. Mine (on Linux Manjaro):
His (on a Mac):
|
Can you work on taking Doctrine out of the equation? This looks like a libxml bug. The behavior I expect when setting
|
I've been investigating a bit more, because this problem comes up for me in one project, but not in another. Let's call these two projects A and B respectively. I've been adding/removing packages in the two projects in order to synchronize them more. What I discovered is that it seems to revolve around the
So while I suspect libxml is in a way involved, correctly defining and updating my packages also seems to solve things. |
Not sure what is going on anymore. I did the above procedure with 90% of my project deleted. When I apply it to the full project, the |
@greg0ire I tried as you said Created a little sandbox project with the following files:
index.php:
Then:
Output:
Does this help? I assume it indicates a couple of errors in the XML-definition |
This is intresting: https://discourse.gnome.org/t/libxml2-2-12-0-released/18063
|
Yeah that's 99% it. My colleague who is on version 2.9.13 doesn't have these errors. In terms of solutions, I'm afraid they all go over my head. The most reliable way forward for us is probably to rewrite our code so it doesn't use the FOS UserBundle anymore. Unfortunately, we will need to do this for multiple projects. |
💡 OK I think I get it
|
Exactly, the error concerns the schema file (doctrine-mapping.xsd), not the current xml file that needs to be checked. |
OK, well, let's take a look at the first error found by @yard-mschwartz I guess…
It refers to this: Lines 146 to 156 in 2b91edc
Let's try to get more info on that error, maybe from the PR that introduced it? There should be a commit labeled "regexp: Fix determinism checks" in libxml. EDIT: here is the commit, couldn't find a PR for it: https://github.com/GNOME/libxml2/commits/a06eaa6119ca5b296b8105dc8c9a34ed5fc1f338 Related issue: https://gitlab.gnome.org/GNOME/libxml2/-/issues/624 I wonder if this could be caused by the |
[root@host ~]# ea-php82 -i | grep libxml
[...snip...]
libxml Version => 2.12.2
libxml
libxml2 Version => 2.12.2
libxslt compiled against libxml Version => 2.9.1 Linked files as they are now: [root@host ~]# ea-php82 parse.php
<pre>array(5) {
[0]=>
object(LibXMLError)#2 (6) {
["level"]=>
int(2)
["code"]=>
int(3070)
["column"]=>
int(0)
["message"]=>
string(77) "complex type 'sql-result-set-mapping': The content model is not determinist.
"
["file"]=>
string(26) "/root/doctrine-mapping.xsd"
["line"]=>
int(146)
}
[1]=>
object(LibXMLError)#3 (6) {
["level"]=>
int(2)
["code"]=>
int(3070)
["column"]=>
int(0)
["message"]=>
string(72) "complex type 'mapped-superclass': The content model is not determinist.
"
["file"]=>
string(26) "/root/doctrine-mapping.xsd"
["line"]=>
int(227)
}
[2]=>
object(LibXMLError)#4 (6) {
["level"]=>
int(2)
["code"]=>
int(3070)
["column"]=>
int(0)
["message"]=>
string(65) "complex type 'embeddable': The content model is not determinist.
"
["file"]=>
string(26) "/root/doctrine-mapping.xsd"
["line"]=>
int(238)
}
[3]=>
object(LibXMLError)#5 (6) {
["level"]=>
int(2)
["code"]=>
int(3070)
["column"]=>
int(0)
["message"]=>
string(66) "complex type 'many-to-one': The content model is not determinist.
"
["file"]=>
string(26) "/root/doctrine-mapping.xsd"
["line"]=>
int(561)
}
[4]=>
object(LibXMLError)#6 (6) {
["level"]=>
int(2)
["code"]=>
int(3070)
["column"]=>
int(0)
["message"]=>
string(65) "complex type 'one-to-one': The content model is not determinist.
"
["file"]=>
string(26) "/root/doctrine-mapping.xsd"
["line"]=>
int(579)
}
}
</pre> After commenting the [root@host ~]# ea-php82 parse.php
<pre>array(4) {
[0]=>
object(LibXMLError)#2 (6) {
["level"]=>
int(2)
["code"]=>
int(3070)
["column"]=>
int(0)
["message"]=>
string(72) "complex type 'mapped-superclass': The content model is not determinist.
"
["file"]=>
string(26) "/root/doctrine-mapping.xsd"
["line"]=>
int(227)
}
[1]=>
object(LibXMLError)#3 (6) {
["level"]=>
int(2)
["code"]=>
int(3070)
["column"]=>
int(0)
["message"]=>
string(65) "complex type 'embeddable': The content model is not determinist.
"
["file"]=>
string(26) "/root/doctrine-mapping.xsd"
["line"]=>
int(238)
}
[2]=>
object(LibXMLError)#4 (6) {
["level"]=>
int(2)
["code"]=>
int(3070)
["column"]=>
int(0)
["message"]=>
string(66) "complex type 'many-to-one': The content model is not determinist.
"
["file"]=>
string(26) "/root/doctrine-mapping.xsd"
["line"]=>
int(561)
}
[3]=>
object(LibXMLError)#5 (6) {
["level"]=>
int(2)
["code"]=>
int(3070)
["column"]=>
int(0)
["message"]=>
string(65) "complex type 'one-to-one': The content model is not determinist.
"
["file"]=>
string(26) "/root/doctrine-mapping.xsd"
["line"]=>
int(579)
}
}
</pre> So, yes, it does appear to be related to those tags and the issue reported by @shyim with Shopware's XSD at least looks somewhat related. It's not all of the any's, either. This passes for <xs:complexType name="sql-result-set-mapping">
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="entity-result" type="orm:entity-result"/>
<xs:element name="column-result" type="orm:column-result"/>
<!-- <xs:any minOccurs="0" maxOccurs="unbounded" namespace="##other"/> -->
</xs:choice>
<xs:any minOccurs="0" maxOccurs="unbounded" namespace="##other"/>
</xs:choice>
<xs:attribute name="name" type="xs:string" use="required" />
</xs:complexType> |
This is worrying: https://www.xml.com/axml/notes/Determinism.html Translating the original
If you try commenting out the other |
When you know exactly which elements will be inside the XML I would get rid of the |
Looking at the repository history, I can find this commit by myself: 12babcc This is interesting as well: doctrine-extensions/DoctrineExtensions#2613 |
Yeah, there's a whole chain of issues on the DoctrineExtensions repo about the XML mappings and validation issues in general, which to my understanding of doctrine-extensions/DoctrineExtensions#2055 haven't even worked with the MongoDB ODM for years since they went strict on their schema and totally disallowed extending like the ORM had allowed. |
A way out of this would be to make the default schema stricter (remove all the |
Hello ! I've got the same issue, and I don't understand how to solve it. I've tried what I've seen here, but nothing changes. The problem appeared when I tried to upgrade my Project from Symfony 6.3 to 6.4. My libxml version is 2.9.1 |
Hi @AlbanDeveloppeur, from our current understanding the problem should only occur with libxml 2.12 onwards. Are you sure it's the same issue? Perhaps the error is the same, but the cause is different (e.g. you're not using |
I work with Summary In the development environnement I have this error message when I try to use
And when I'm in production environnement, I have this error message :
So for now, it seems to be the same problem you've discovered here. After a lot of manipulations, I tried to delete some vendors. And after deleting I don't know why this vendor created this type of issue, but in my case, deleting this vendor solved my problem. |
It does seem to be the same error. How did you determine the libxml version? I think looking at the output of |
Hello |
Using PHP 8.2.14 (compiled against libxml 2.12.0) with a Symfony 7 app. This issue basically renders Symfony unusable. You can not use Can confirm though that the removal of |
Don't use 2.12.0 or 2.12.1, those versions had bugs causing PHP to segfault. php/php-src#12847 |
As far as I know the version 2.12.3 should run fine, but it produces the same error. |
2.12.3 might not have the segmentation fault, but I see no reason why it would no longer have the schema validation error. |
Can confirm |
Don't really know if this is a fix or just some cheat. I've had this problem which seems to be originating from Some probably useful info: $ php -i | grep libxml
libxml Version => 2.12.3
libxml
libxml2 Version => 2.12.3
libxslt compiled against libxml Version => 2.12.0 $ php -v
PHP 8.2.14 (cli) (built: Dec 21 2023 14:02:51) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.14, Copyright (c) Zend Technologies
with Zend OPcache v8.2.14, Copyright (c), by Zend Technologies
with Xdebug v3.2.2, Copyright (c) 2002-2023, by Derick Rethans A little excerpt from my {
"require": {
"php": "^8.1.0",
"doctrine/orm": "^2.18|^3",
"gesdinet/jwt-refresh-token-bundle": "^1.1"
}
} I'm on Symfony version |
It's a cheat. That |
still facing
|
@IndraGunawan why do you expect it to be fixed? |
I have the same issue cause by : |
@greg0ire the issue was on libxml, is it? or xsd file needs some changes? i downgraded libxml2 to 2.11.6 and compile the PHP 8.3.1. i don't see
|
Why are you using the past tense? The issue still exists. Because of new libxml versions that are stricter since libxml 2.12, the XSD file is now considered invalid, and will need some changes, yes. |
@greg0ire so we need to update XSD file to make it valid, and the issue is solved ? |
Yes, but how we update it might cause issues to other users. For instance, @mbabker maintains a library that relies on adding extra elements to the mapping file (see doctrine-extensions/DoctrineExtensions#2318). Right now, I think it works thanks to these This is why a solution could be to allow custom schemas: #11123 . Users who would need to use extensions could specify a more complicated schema allowing for them. Such schemas could be maintained by libraries, so they would use e.g. |
@mbabker could you maybe work on producing an XSD file that:
|
Note that it's possible to reproduce the issue without PHP, like this: $ xmllint --schema doctrine-mapping.xsd tests/Doctrine/Tests/ORM/Mapping/xml/DDC2429Book.orm.xml --noout
doctrine-mapping.xsd:175: element complexType: Schemas parser error : complex type 'mapped-superclass': The content model is not determinist.
doctrine-mapping.xsd:186: element complexType: Schemas parser error : complex type 'embeddable': The content model is not determinist.
doctrine-mapping.xsd:506: element complexType: Schemas parser error : complex type 'many-to-one': The content model is not determinist.
doctrine-mapping.xsd:524: element complexType: Schemas parser error : complex type 'one-to-one': The content model is not determinist.
WXS schema doctrine-mapping.xsd failed to compile Applying the following patch appears to fix the issue: diff --git a/doctrine-mapping.xsd b/doctrine-mapping.xsd
index 5d6dfc812..67e2ac438 100644
--- a/doctrine-mapping.xsd
+++ b/doctrine-mapping.xsd
@@ -176,7 +176,6 @@
<xs:complexContent>
<xs:extension base="orm:entity">
<xs:choice minOccurs="0" maxOccurs="unbounded">
- <xs:any minOccurs="0" maxOccurs="unbounded" namespace="##other"/>
</xs:choice>
<xs:anyAttribute namespace="##other"/>
</xs:extension>
@@ -187,7 +186,6 @@
<xs:complexContent>
<xs:extension base="orm:entity">
<xs:choice minOccurs="0" maxOccurs="unbounded">
- <xs:any minOccurs="0" maxOccurs="unbounded" namespace="##other"/>
</xs:choice>
</xs:extension>
</xs:complexContent>
@@ -510,7 +508,6 @@
<xs:choice minOccurs="0" maxOccurs="1">
<xs:element name="join-column" type="orm:join-column"/>
<xs:element name="join-columns" type="orm:join-columns"/>
- <xs:any minOccurs="0" maxOccurs="unbounded" namespace="##other"/>
</xs:choice>
<xs:any minOccurs="0" maxOccurs="unbounded" namespace="##other"/>
</xs:choice>
@@ -528,7 +525,6 @@
<xs:choice minOccurs="0" maxOccurs="1">
<xs:element name="join-column" type="orm:join-column"/>
<xs:element name="join-columns" type="orm:join-columns"/>
- <xs:any minOccurs="0" maxOccurs="unbounded" namespace="##other"/>
</xs:choice>
<xs:any minOccurs="0" maxOccurs="unbounded" namespace="##other"/>
</xs:choice> |
$ /usr/local/opt/libxml2/bin/xmllint --version
/usr/local/opt/libxml2/bin/xmllint: using libxml version 21203
compiled with: Threads Tree Output Push Reader Patterns Writer SAXv1 HTTP DTDValid HTML C14N Catalog XPath XPointer XInclude Iconv ICU ISO8859X Unicode Regexps Automata Schemas Schematron Modules Debug Zlib Running <?xml version="1.0" encoding="UTF-8"?>
<schema elementFormDefault="qualified" xmlns="http://www.w3.org/2001/XMLSchema">
<import namespace="http://doctrine-project.org/schemas/orm/doctrine-mapping" schemaLocation="./vendor/doctrine/orm/doctrine-mapping.xsd"/>
<import namespace="http://gediminasm.org/schemas/orm/doctrine-extensions-mapping" schemaLocation="./vendor/gedmo/doctrine-extensions/schemas/orm/doctrine-extensions-mapping-2-2.xsd"/>
</schema> $ /usr/local/opt/libxml2/bin/xmllint --schema doctrine-mapping.xsd Sluggable.dcm.xml --noout
vendor/doctrine/orm/doctrine-mapping.xsd:146: element complexType: Schemas parser error : complex type 'sql-result-set-mapping': The content model is not determinist.
vendor/doctrine/orm/doctrine-mapping.xsd:227: element complexType: Schemas parser error : complex type 'mapped-superclass': The content model is not determinist.
vendor/doctrine/orm/doctrine-mapping.xsd:238: element complexType: Schemas parser error : complex type 'embeddable': The content model is not determinist.
vendor/doctrine/orm/doctrine-mapping.xsd:561: element complexType: Schemas parser error : complex type 'many-to-one': The content model is not determinist.
vendor/doctrine/orm/doctrine-mapping.xsd:579: element complexType: Schemas parser error : complex type 'one-to-one': The content model is not determinist.
WXS schema doctrine-mapping.xsd failed to compile With this diff (based on the 2.17.2 tag), it validates: diff --git a/doctrine-mapping.xsd b/doctrine-mapping.xsd
index a9b1a367e..4c78c805c 100644
--- a/doctrine-mapping.xsd
+++ b/doctrine-mapping.xsd
@@ -148,7 +148,7 @@
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="entity-result" type="orm:entity-result"/>
<xs:element name="column-result" type="orm:column-result"/>
- <xs:any minOccurs="0" maxOccurs="unbounded" namespace="##other"/>
+ <!-- <xs:any minOccurs="0" maxOccurs="unbounded" namespace="##other"/> -->
</xs:choice>
<xs:any minOccurs="0" maxOccurs="unbounded" namespace="##other"/>
</xs:choice>
@@ -228,7 +228,7 @@
<xs:complexContent>
<xs:extension base="orm:entity">
<xs:choice minOccurs="0" maxOccurs="unbounded">
- <xs:any minOccurs="0" maxOccurs="unbounded" namespace="##other"/>
+ <!-- <xs:any minOccurs="0" maxOccurs="unbounded" namespace="##other"/> -->
</xs:choice>
<xs:anyAttribute namespace="##other"/>
</xs:extension>
@@ -239,7 +239,7 @@
<xs:complexContent>
<xs:extension base="orm:entity">
<xs:choice minOccurs="0" maxOccurs="unbounded">
- <xs:any minOccurs="0" maxOccurs="unbounded" namespace="##other"/>
+ <!-- <xs:any minOccurs="0" maxOccurs="unbounded" namespace="##other"/> -->
</xs:choice>
</xs:extension>
</xs:complexContent>
@@ -565,7 +565,7 @@
<xs:choice minOccurs="0" maxOccurs="1">
<xs:element name="join-column" type="orm:join-column"/>
<xs:element name="join-columns" type="orm:join-columns"/>
- <xs:any minOccurs="0" maxOccurs="unbounded" namespace="##other"/>
+ <!-- <xs:any minOccurs="0" maxOccurs="unbounded" namespace="##other"/> -->
</xs:choice>
<xs:any minOccurs="0" maxOccurs="unbounded" namespace="##other"/>
</xs:choice>
@@ -583,7 +583,7 @@
<xs:choice minOccurs="0" maxOccurs="1">
<xs:element name="join-column" type="orm:join-column"/>
<xs:element name="join-columns" type="orm:join-columns"/>
- <xs:any minOccurs="0" maxOccurs="unbounded" namespace="##other"/>
+ <!-- <xs:any minOccurs="0" maxOccurs="unbounded" namespace="##other"/> -->
</xs:choice>
<xs:any minOccurs="0" maxOccurs="unbounded" namespace="##other"/>
</xs:choice> |
The "any" tags inside the definition for mapped superclasses and embeddables duplicate what is already done for entities. The other removed "any" tags are also redundant, as they duplicate what's already done inside the grandparent "choice" tag. Starting with version libxml 2.12, such redundant tags cause errors about the content model not being "determinist". Fixes doctrine#11117
Thanks @greg0ire for fixing this nasty problem. EDIT My bad, it's already in 2.17.3. Thanks again! |
BC Break Report
Summary
Currently upgrading one our projects to PHP 8.2 from PHP 7.4. Application runs fine on PHP 7.4 with
doctrine/orm
already on 2.17.1. However, when I bump the PHP-version to^8.2
and runcomposer upgrade
, the subsequentsymfony console cache:clear
fails with anWarning: DOMDocument::schemaValidate(): Invalid Schema
error.Previous behavior
The commands
symfony console cache:clear
works just fine.Current behavior
When I bump the PHP-version to
^8.2
and runcomposer upgrade
, the subsequentsymfony console cache:clear
fails with the following error:Line 1006 is the
schemaValidate()
in the following code block in[...]/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php
:When I dump the
$file
that's being processed, it outputs[...]/vendor/friendsofsymfony/user-bundle/Resources/config/doctrine-mapping/User.orm.xml
. So you might think this problem is related to that particular bundle, where I also created an issue, however that packages also didn't change versions during the version bump to PHP 8.2. Bothdoctrine/orm
andfriendsofsymfony/user-bundle
were already on the latest version.I messed around a little bit, to see if I could get some more info on the error. If I change the first line of that code block to
$backedUpErrorSetting = libxml_use_internal_errors(false);
, it shows a bit more information:I assume I have an error somewhere in my model definition, that somehow was acceptable before the upgrade, but I have a hard time pinpointing where that might be. The
friendsofsymfony/user-bundle
file looks fine, and also works fine in another project we upgraded to PHP 8.2.EDIT package overview and User model removed, because in the end they had nothing to do with this issue
Any suggestions?
The text was updated successfully, but these errors were encountered: