doctrine / orm

Doctrine Object Relational Mapper (ORM)
https://www.doctrine-project.org/projects/orm.html
MIT License
9.94k stars 2.52k forks source link

DOMDocument schemaValidate error migrating to PHP 8.2 #11117

Closed yard-mschwartz closed 10 months ago

yard-mschwartz commented 11 months ago

BC Break Report

Q A
BC Break not sure
Version 2.17.1 (latest at time of writing)

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 run composer upgrade, the subsequent symfony console cache:clear fails with an Warning: 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 run composer upgrade, the subsequent symfony console cache:clear fails with the following error:

 [WARNING] Some commands could not be registered:                                                                       

In XmlDriver.php line 1006:

  Warning: DOMDocument::schemaValidate(): Invalid Schema

Line 1006 is the schemaValidate() in the following code block in [...]/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php:

$backedUpErrorSetting = libxml_use_internal_errors(true);

try {
    $document = new DOMDocument();
    $document->load($file);

    if (! $document->schemaValidate(__DIR__ . '/../../../../../doctrine-mapping.xsd')) {
        throw MappingException::fromLibXmlErrors(libxml_get_errors());
    }

    // more code here
}

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. Both doctrine/orm and friendsofsymfony/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:

 [WARNING] Some commands could not be registered:                                                                       

In XmlDriver.php line 1006:

  Warning: DOMDocument::schemaValidate(): complex type 'sql-result-set-mapping': The content model is not determinist.

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?

greg0ire commented 11 months ago

Hi! :wave: After reading this, I think I should have added an @. Can you try restoring the code to its initial state then adding an @, like so:

-if (! @$document->schemaValidate(__DIR__ . '/../../../../../doctrine-mapping.xsd')) {
+if (! $document->schemaValidate(__DIR__ . '/../../../../../doctrine-mapping.xsd')) {

After that, you should get a detailed error message.

mleko64 commented 11 months ago

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: 1) Some error in libxml2 library starting from version 2.12.x 2) There are new changes in the new version of libxml2 to which the "doctrine-mapping.xsd" file must be adapted.

yard-mschwartz commented 11 months ago

Hi @greg0ire . If I add the @-sign, the symfony console cache:clear command finishes normally as expected. No errors come up.

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):

$ xmllint --version
xmllint: using libxml version 21202-GITv2.12.2
   compiled with: Threads Tree Output Push Reader Patterns Writer SAXv1 HTTP DTDValid HTML Legacy C14N Catalog XPath XPointer XInclude Iconv ICU ISO8859X Unicode Regexps Automata Schemas Schematron Modules Debug Zlib Lzma 

His (on a Mac):

$ xmllint --version
xmllint: using libxml version 20913
   compiled with: Threads Tree Output Push Reader Patterns Writer SAXv1 FTP HTTP DTDValid HTML Legacy C14N Catalog XPath XPointer XInclude ICU ISO8859X Unicode Regexps Automata Schemas Schematron Modules Debug Zlib
greg0ire commented 11 months ago

Can you work on taking Doctrine out of the equation? This looks like a libxml bug. The behavior I expect when setting libxml_use_internal_errors to true is:

yard-mschwartz commented 11 months ago

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 doctrine/annotations package. It needs to be on v2.

So while I suspect libxml is in a way involved, correctly defining and updating my packages also seems to solve things.

yard-mschwartz commented 11 months ago

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 Invalid Schema warning is back. My brain hurts and I should probably take a break. :sweat_smile:

yard-mschwartz commented 11 months ago

@greg0ire I tried as you said

Created a little sandbox project with the following files:

index.php:

<?php

libxml_use_internal_errors(true);

try {
    $document = new DOMDocument();
    $document->load('User.orm.xml');

    if (! $document->schemaValidate('doctrine-mapping.xsd')) {
        print('<pre>');
        var_dump(libxml_get_errors());
        print('</pre>');
    }
} finally {
    libxml_clear_errors();
}

Then:

Output:

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(63) "[.../]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(63) "[.../]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(63) "[.../]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(63) "[.../]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(63) "[.../]doctrine-mapping.xsd"
    ["line"]=>
    int(579)
  }
}

Does this help? I assume it indicates a couple of errors in the XML-definition

mleko64 commented 11 months ago

This is intresting: https://discourse.gnome.org/t/libxml2-2-12-0-released/18063

Several bugs in the regex determinism checks were fixed. Invalid XML Schemas which previous versions erroneously accepted will now be rejected.

yard-mschwartz commented 11 months ago

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.

greg0ire commented 11 months ago

:bulb: OK I think I get it

mleko64 commented 11 months ago

Exactly, the error concerns the schema file (doctrine-mapping.xsd), not the current xml file that needs to be checked.

greg0ire commented 11 months ago

OK, well, let's take a look at the first error found by @yard-mschwartz I guess…

complex type 'sql-result-set-mapping': The content model is not determinist.

It refers to this: https://github.com/doctrine/orm/blob/2b91edc525bde4f23f9ada22a82c021b5c18c92b/doctrine-mapping.xsd#L146-L156

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 <xs:any tags in the schema… given their name, they sound like they could allow anything. If somebody with the error can try removing them and see if they still get the error about sql-result-set-mapping, that would help.

mbabker commented 11 months ago
[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 <xs:any tag in the sql-result-set-mapping type:

[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 sql-result-set-mapping:

  <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>
greg0ire commented 11 months ago

This is worrying: https://www.xml.com/axml/notes/Determinism.html This is a bit more understandable: https://www.xml.com/axml/target.html#determinism

Translating the original sql-result-set-mapping into english, I think it says that when you have a tag sql-result-set-mapping, then you can must have a name attribute, and then inside you can have one of:

If you try commenting out the other any, and not the first, does it also pass? If yes, this might mean that when you put something that isn't entity-result or column-result in there, it doesn't know whether it should validated that against the first any, or the second one?

shyim commented 11 months ago

When you know exactly which elements will be inside the XML I would get rid of the xsd:any. In our case it was allowed to add custom elements which were not described in the xsd.

greg0ire commented 11 months ago

Looking at the repository history, I can find this commit by myself: 12babcc1c24759002605057b79e5bc6f93e3bf0a

This is interesting as well: https://github.com/doctrine-extensions/DoctrineExtensions/issues/2613

mbabker commented 11 months ago

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 https://github.com/doctrine-extensions/DoctrineExtensions/issues/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.

greg0ire commented 11 months ago

A way out of this would be to make the default schema stricter (remove all the xs:any), so that it validates, and then allow defining custom schemas: https://github.com/doctrine/orm/issues/11123

AlbanDeveloppeur commented 11 months ago

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

yard-mschwartz commented 11 months ago

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 friendsofsymfony/user-bundle)

AlbanDeveloppeur commented 11 months ago

I work with Symfony : 6.4.1 PHP : 8.2.10 doctrine/orm : 2.17.2 vich/uploader-bundle : 2.3.0 libxml : 2.9.1

Summary Hello ! To update my issue from this comment : https://github.com/doctrine/orm/issues/11117#issuecomment-1864457851

In the development environnement I have this error message when I try to use php bin/console cache:clear

Warning: DOMDocument::schemaValidate(): Invalid Schema

And when I'm in production environnement, I have this error message :

In MappingException.php line 1004:

libxml error: complex type 'mapped-superclass': The content model is not determinist.
in /home/admin/preprod/vendor/doctrine/orm/doctrine-mapping.xsd atline 227

libxml error: complex type 'embeddable': The content model is not determinist.
in /home/admin/preprod/vendor/doctrine/orm/doctrine-mapping.xsd at line 238

libxml error: complex type 'many-to-one': The content model is not determinist.
in /home/admin/preprod/vendor/doctrine/orm/doctrine-mapping.xsd at line 561

libxml error: complex type 'one-to-one': The content model is not determinist.
in /home/admin/preprod/vendor/doctrine/orm/doctrine-mapping.xsd at line 579

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 vich/uploader-bundle, both errors in the development and production environment have disappeared and I can do php bin/console cache:clear again.

I don't know why this vendor created this type of issue, but in my case, deleting this vendor solved my problem.

greg0ire commented 11 months ago

It does seem to be the same error. How did you determine the libxml version? I think looking at the output of php -i might be the right way to do this in case it's possible to have several different versions on your system

aratinau commented 10 months ago

Hello I have exactly the same problem, the only bundle I added is symfonycasts/verify-email-bundle

danielsreichenbach commented 10 months ago

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 make:entity or any other Doctrine workflow.

Can confirm though that the removal of xsd:any from doctrine-mapping.xsd makes things work again.

mbabker commented 10 months ago

Don't use 2.12.0 or 2.12.1, those versions had bugs causing PHP to segfault. https://github.com/php/php-src/issues/12847

justpilot commented 10 months ago
php -i | grep libxml

libxml Version => 2.12.3
libxml
libxml2 Version => 2.12.3
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
pacman -Ss libxml

core/libxml2 2.12.3-1 [installed]
    XML C parser and toolkit

extra/libxmlb 0.3.14-1 [installed]
    Library to help create and query binary XML blobs

extra/python-lxml 4.9.2-3 [installed]
    Python3 binding for the libxml2 and libxslt libraries

As far as I know the version 2.12.3 should run fine, but it produces the same error.

greg0ire commented 10 months ago

As far as I know the version 2.12.3 should run fine

2.12.3 might not have the segmentation fault, but I see no reason why it would no longer have the schema validation error.

danielsreichenbach commented 10 months ago

Can confirm 2.12.3 still causes the schema validation error. Only remedy still remains xsd:any change.

japodhidev commented 10 months ago

Don't really know if this is a fix or just some cheat. I've had this problem which seems to be originating from gesdinet/jwt-refresh-token-bundle . I came across https://github.com/doctrine-extensions/DoctrineExtensions/issues/2613 which suggested setting validate_xml_mapping: false. This seemed to fix my issue.

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 composer.json

{
    "require": {
        "php": "^8.1.0",
        "doctrine/orm": "^2.18|^3",
        "gesdinet/jwt-refresh-token-bundle": "^1.1"
     }
}

I'm on Symfony version 6.4.2. Hope this sheds some light or possibly helps someone someway.

mbabker commented 10 months ago

Don't really know if this is a fix or just some cheat.

It's a cheat. That validate_xml_mapping setting disables the XML schema validation, preventing the error in this thread from being triggered in the first place. And IIRC, that setting is no-op'd with ORM 3 and XML validation is always required.

IndraGunawan commented 10 months ago

still facing DOMDocument::schemaValidate(): Invalid Schema error on libxml2 from HEAD commit

php -i | grep libxml 
libxml Version => 2.13.0
libxml
libxml2 Version => 2.13.0
php -v
PHP 8.3.1 (cli) (built: Jan 15 2024 23:10:16) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.3.1, Copyright (c) Zend Technologies
greg0ire commented 10 months ago

@IndraGunawan why do you expect it to be fixed?

eliphazbouye commented 10 months ago

I have the same issue cause by : vich/uploader-bundle

IndraGunawan commented 10 months ago

why do you expect it to be fixed?

@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 invalid schema error

php -i | grep libxml            
libxml Version => 2.11.6
libxml
libxml2 Version => 2.11.6
greg0ire commented 10 months ago

the issue was on libxml

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.

eliphazbouye commented 10 months ago

@greg0ire so we need to update XSD file to make it valid, and the issue is solved ?

greg0ire commented 10 months ago

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 https://github.com/doctrine-extensions/DoctrineExtensions/issues/2318). Right now, I think it works thanks to these any elements we need to remove.

This is why a solution could be to allow custom schemas: https://github.com/doctrine/orm/issues/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. vendor/doctrine-extensions/DoctrineExtensions/extended-schema.xsd.

greg0ire commented 10 months ago

@mbabker could you maybe work on producing an XSD file that:

greg0ire commented 10 months ago

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>
mbabker commented 10 months ago
$ /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 xmllint against this file with the below schema which imports the ORM 2.17.2 XSD and the doctrine-extensions 3.14.0 XSD:

<?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>
yard-mschwartz commented 10 months ago

Thanks @greg0ire for fixing this nasty problem. If I'm not mistaken, the fix seems to be scheduled for 2.18.x. When can I expect 2.18.0 to be made available to the general public?

EDIT My bad, it's already in 2.17.3. Thanks again!