libxml2 无法加载 Doctrine 实体元数据
libxml2 cannot load Doctrine entity metadata
我遇到了一个关于 Doctrine 的非常奇怪的问题。它无法加载特定实体的元数据。我的所有其他实体都加载正常,但是当我尝试加载以下内容时 XML 它失败了:
<?xml version="1.0" encoding="UTF-8"?>
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
<entity name="Foo\ContentBundle\Entity\Item" table="content_item">
<id name="id" column="id" type="integer">
<generator strategy="AUTO" />
</id>
<field name="gid" column="gid" type="string" nullable="false" unique="false" />
<field name="url" column="url" type="string" nullable="true" unique="false" />
<field name="title" column="title" type="string" nullable="false" unique="false" />
<field name="content" column="content" type="text" nullable="false" unique="false" />
<field name="timestamp" column="timestamp" type="datetime" nullable="false" unique="false" />
<many-to-one field="feed" target-entity="Foo\ContentBundle\Entity\Feed">
<join-column name="feed" referenced-column-name="id" nullable="false" on-delete="CASCADE" />
</many-to-one>
</entity>
它抛出以下异常:
Invalid mapping file 'Foo.ContentBundle.Entity.Item.orm.xml' for class 'Foo\ContentBundle\Entity\Item'.
而 libxml2 给出了以下错误:
failed to load external entity "/Users/ramon/Development/foo/src/Foo/ContentBundle/Resources/config/doctrine/Item.orm.xml"
奇怪的是,我所有的其他实体都很好!有人知道如何解决这个问题吗?
我正在使用 libxml 版本 2.9.0、Doctrine ORM 版本 2.4.7 和 Symfony 版本 2.6,以及 PHP 5.6.5。
[edit] 忘了最好的部分:这只发生在我加载元数据以从存储库中获取实体时。不是在我将实体插入存储库时。
此外,当我尝试使用 simplexml_load_file
手动加载文件时,它工作正常。
我找到了原因。
我正在为 picoFeed 使用另一个库(picoFeed) which calls the libxml_disable_entity_loader(true)
function which in turn causes an known bug. I've now created a pull request,它在完成安全检查后启用实体加载器。这解决了上述问题。
我遇到了一个关于 Doctrine 的非常奇怪的问题。它无法加载特定实体的元数据。我的所有其他实体都加载正常,但是当我尝试加载以下内容时 XML 它失败了:
<?xml version="1.0" encoding="UTF-8"?>
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
<entity name="Foo\ContentBundle\Entity\Item" table="content_item">
<id name="id" column="id" type="integer">
<generator strategy="AUTO" />
</id>
<field name="gid" column="gid" type="string" nullable="false" unique="false" />
<field name="url" column="url" type="string" nullable="true" unique="false" />
<field name="title" column="title" type="string" nullable="false" unique="false" />
<field name="content" column="content" type="text" nullable="false" unique="false" />
<field name="timestamp" column="timestamp" type="datetime" nullable="false" unique="false" />
<many-to-one field="feed" target-entity="Foo\ContentBundle\Entity\Feed">
<join-column name="feed" referenced-column-name="id" nullable="false" on-delete="CASCADE" />
</many-to-one>
</entity>
它抛出以下异常:
Invalid mapping file 'Foo.ContentBundle.Entity.Item.orm.xml' for class 'Foo\ContentBundle\Entity\Item'.
而 libxml2 给出了以下错误:
failed to load external entity "/Users/ramon/Development/foo/src/Foo/ContentBundle/Resources/config/doctrine/Item.orm.xml"
奇怪的是,我所有的其他实体都很好!有人知道如何解决这个问题吗?
我正在使用 libxml 版本 2.9.0、Doctrine ORM 版本 2.4.7 和 Symfony 版本 2.6,以及 PHP 5.6.5。
[edit] 忘了最好的部分:这只发生在我加载元数据以从存储库中获取实体时。不是在我将实体插入存储库时。
此外,当我尝试使用 simplexml_load_file
手动加载文件时,它工作正常。
我找到了原因。
我正在为 picoFeed 使用另一个库(picoFeed) which calls the libxml_disable_entity_loader(true)
function which in turn causes an known bug. I've now created a pull request,它在完成安全检查后启用实体加载器。这解决了上述问题。