Symfony2:CRUD编辑视图中的“无效架构”

时间:2013-03-13 10:58:07

标签: php xml symfony symfony-2.0

我们有一个运行Symfony版本 2.0.17 的网站(是的,我们知道它已经过时,正在迁移到2.2.x)。几天前,我们开始收到错误500 ,并且收到此消息后,它一直运行良好:

  

警告:DOMDocument :: schemaValidate():/var/www/customers/customername/symfony/vendor/symfony/src/Symfony/Component/Validator/Mapping/Loader/XmlFileLoader.php第197行中的无效架构

当我们尝试使用FormBuilder创建编辑表单时,会发生错误。在我们的开发和测试环境中,一切都运行良好,这使得排除故障成为一个巨大的痛苦。

这个问题的可能原因是什么?自1月份以来,该网站没有任何新的变化,并且在3月初确实有效,因为这是最新发布内容的时间戳。

这是完整堆栈跟踪的相关部分。 DOMDocument->schemaValidate()是导致警告的方法。

at DOMDocument ->schemaValidate ('/var/www/customers/customername/symfony/vendor/symfony/src/Symfony/Component/Validator/Mapping/Loader/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd') 
  in /var/www/customers/customername/symfony/vendor/symfony/src/Symfony/Component/Validator/Mapping/Loader/XmlFileLoader.php at line 197    
at XmlFileLoader ->parseFile ('/var/www/customers/customername/symfony/vendor/symfony/src/Symfony/Component/Form/Resources/config/validation.xml') 
  in /var/www/customers/customername/symfony/vendor/symfony/src/Symfony/Component/Validator/Mapping/Loader/XmlFileLoader.php at line 32    
at XmlFileLoader ->loadClassMetadata (object(ClassMetadata)) 
  in /var/www/customers/customername/symfony/vendor/symfony/src/Symfony/Component/Validator/Mapping/Loader/LoaderChain.php at line 57    
at LoaderChain ->loadClassMetadata (object(ClassMetadata)) 
  in /var/www/customers/customername/symfony/vendor/symfony/src/Symfony/Component/Validator/Mapping/Loader/LoaderChain.php at line 57    
at LoaderChain ->loadClassMetadata (object(ClassMetadata)) 
  in /var/www/customers/customername/symfony/vendor/symfony/src/Symfony/Component/Validator/Mapping/ClassMetadataFactory.php at line 68    
at ClassMetadataFactory ->getClassMetadata ('OurCompany\OurCMSBundle\SearchableInterface') 
  in /var/www/customers/customername/symfony/vendor/symfony/src/Symfony/Component/Validator/Mapping/ClassMetadataFactory.php at line 65    
at ClassMetadataFactory ->getClassMetadata ('OurCompany\OurCMSBundle\Entity\News') 
  in /var/www/customers/customername/symfony/vendor/symfony/src/Symfony/Component/Form/Extension/Validator/ValidatorTypeGuesser.php at line 314    
at ValidatorTypeGuesser ->guess ('OurCompany\OurCMSBundle\Entity\News', 'title', object(Closure)) 
  in /var/www/customers/customername/symfony/vendor/symfony/src/Symfony/Component/Form/Extension/Validator/ValidatorTypeGuesser.php at line 39    
at ValidatorTypeGuesser ->guessType ('OurCompany\OurCMSBundle\Entity\News', 'title') 
  in /var/www/customers/customername/symfony/vendor/symfony/src/Symfony/Component/Form/FormTypeGuesserChain.php at line 46    
at Symfony\Component\Form\{closure} (object(ValidatorTypeGuesser)) 
  in /var/www/customers/customername/symfony/vendor/symfony/src/Symfony/Component/Form/FormTypeGuesserChain.php at line 85    
at FormTypeGuesserChain ->guess (object(Closure)) 
  in /var/www/customers/customername/symfony/vendor/symfony/src/Symfony/Component/Form/FormTypeGuesserChain.php at line 47    
at FormTypeGuesserChain ->guessType ('OurCompany\OurCMSBundle\Entity\News', 'title') 
  in /var/www/customers/customername/symfony/vendor/symfony/src/Symfony/Component/Form/FormFactory.php at line 315    
at FormFactory ->createBuilderForProperty ('OurCompany\OurCMSBundle\Entity\News', 'title', null, array()) 
  in /var/www/customers/customername/symfony/vendor/symfony/src/Symfony/Component/Form/FormBuilder.php at line 575    
at FormBuilder ->create ('title', null, array()) 
  in /var/www/customers/customername/symfony/vendor/symfony/src/Symfony/Component/Form/FormBuilder.php at line 691    
at FormBuilder ->buildChildren () 
  in /var/www/customers/customername/symfony/vendor/symfony/src/Symfony/Component/Form/FormBuilder.php at line 654    
at FormBuilder ->getForm () 
  in /var/www/customers/customername/symfony/vendor/symfony/src/Symfony/Component/Form/FormFactory.php at line 138    
at FormFactory ->create (object(NewsType), object(News), array()) 
  in /var/www/customers/customername/symfony/vendor/symfony/src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php at line 129   
at Controller ->createForm (object(NewsType), object(News)) 
  in /var/www/customers/customername/symfony/src/Customer/OurCMSBundle/Controller/NewsController.php at line 127    
at NewsController ->editAction ('2') 

使用的架构是Symfony Validator组件的一部分,位于vendor/symfony/src/Symfony/Component/Validator/Mapping/Loader/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd中。使用w3.org validator进行检查时,它会进行验证。这是架构:

<?xml version="1.0" ?>

<xsd:schema xmlns="http://symfony.com/schema/dic/constraint-mapping"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://symfony.com/schema/dic/constraint-mapping"
    elementFormDefault="qualified">

  <xsd:annotation>
    <xsd:documentation><![CDATA[
      Symfony Validator Constraint Mapping Schema, version 1.0
      Authors: Bernhard Schussek

      A constraint mapping connects classes, properties and getters with
      validation constraints.
    ]]></xsd:documentation>
  </xsd:annotation>

  <xsd:element name="constraint-mapping" type="constraint-mapping" />

  <xsd:complexType name="constraint-mapping">
    <xsd:annotation>
      <xsd:documentation><![CDATA[
        The root element of the constraint mapping definition.
      ]]></xsd:documentation>
    </xsd:annotation>
    <xsd:sequence>
      <xsd:element name="namespace" type="namespace" minOccurs="0" maxOccurs="unbounded" />
      <xsd:element name="class" type="class" maxOccurs="unbounded" />
    </xsd:sequence>
  </xsd:complexType>

  <xsd:complexType name="namespace">
    <xsd:annotation>
      <xsd:documentation><![CDATA[
        Contains the abbreviation for a namespace.
      ]]></xsd:documentation>
    </xsd:annotation>
    <xsd:simpleContent>
      <xsd:extension base="xsd:string">
        <xsd:attribute name="prefix" type="xsd:string" use="required" />
      </xsd:extension>
    </xsd:simpleContent>
  </xsd:complexType>

  <xsd:complexType name="class">
    <xsd:annotation>
      <xsd:documentation><![CDATA[
        Contains constraints for a single class.

        Nested elements may be class constraints, property and/or getter
        definitions.
      ]]></xsd:documentation>
    </xsd:annotation>
    <xsd:choice minOccurs="0" maxOccurs="unbounded">
      <xsd:element name="group-sequence" type="group-sequence" minOccurs="0" maxOccurs="1" />
      <xsd:element name="constraint" type="constraint" minOccurs="0" maxOccurs="unbounded" />
      <xsd:element name="property" type="property" minOccurs="0" maxOccurs="unbounded" />
      <xsd:element name="getter" type="getter" minOccurs="0" maxOccurs="unbounded" />
    </xsd:choice>
    <xsd:attribute name="name" type="xsd:string" use="required" />
  </xsd:complexType>

  <xsd:complexType name="group-sequence">
    <xsd:annotation>
      <xsd:documentation><![CDATA[
        Contains the group sequence of a class. Each group should be written
        into a "value" tag.
      ]]></xsd:documentation>
    </xsd:annotation>
    <xsd:sequence>
      <xsd:element name="value" type="value" minOccurs="1" maxOccurs="unbounded" />
    </xsd:sequence>
  </xsd:complexType>

  <xsd:complexType name="property">
    <xsd:annotation>
      <xsd:documentation><![CDATA[
        Contains constraints for a single property. The name of the property
        should be given in the "name" option.
      ]]></xsd:documentation>
    </xsd:annotation>
    <xsd:sequence>
      <xsd:element name="constraint" type="constraint" maxOccurs="unbounded" />
    </xsd:sequence>
    <xsd:attribute name="name" type="xsd:string" use="required" />
  </xsd:complexType>

  <xsd:complexType name="getter">
    <xsd:annotation>
      <xsd:documentation><![CDATA[
        Contains constraints for a getter method. The name of the corresponding
        property should be given in the "property" option.
      ]]></xsd:documentation>
    </xsd:annotation>
    <xsd:sequence>
      <xsd:element name="constraint" type="constraint" maxOccurs="unbounded" />
    </xsd:sequence>
    <xsd:attribute name="property" type="xsd:string" use="required" />
  </xsd:complexType>

  <xsd:complexType name="constraint" mixed="true">
    <xsd:annotation>
      <xsd:documentation><![CDATA[
        Contains a constraint definition. The name of the constraint should be
        given in the "name" option.

        May contain a single value, multiple "constraint" elements,
        multiple "value" elements or multiple "option" elements.
      ]]></xsd:documentation>
    </xsd:annotation>
    <xsd:choice minOccurs="0">
      <xsd:element name="constraint" type="constraint" minOccurs="1" maxOccurs="unbounded" />
      <xsd:element name="option" type="option" minOccurs="1" maxOccurs="unbounded" />
      <xsd:element name="value" type="value" minOccurs="1" maxOccurs="unbounded" />
    </xsd:choice>
    <xsd:attribute name="name" type="xsd:string" use="required" />
  </xsd:complexType>

  <xsd:complexType name="option" mixed="true">
    <xsd:annotation>
      <xsd:documentation><![CDATA[
        Contains a constraint option definition. The name of the option
        should be given in the "name" option.

        May contain a single value, multiple "value" elements or multiple
        "constraint" elements.
      ]]></xsd:documentation>
    </xsd:annotation>
    <xsd:choice minOccurs="0">
      <xsd:element name="constraint" type="constraint" minOccurs="1" maxOccurs="unbounded" />
      <xsd:element name="value" type="value" minOccurs="1" maxOccurs="unbounded" />
    </xsd:choice>
    <xsd:attribute name="name" type="xsd:string" use="required" />
  </xsd:complexType>

  <xsd:complexType name="value" mixed="true">
    <xsd:annotation>
      <xsd:documentation><![CDATA[
        A value of an element.

        May contain a single value, multiple "value" elements or multiple
        "constraint" elements.
      ]]></xsd:documentation>
    </xsd:annotation>
    <xsd:choice minOccurs="0">
      <xsd:element name="constraint" type="constraint" minOccurs="1" maxOccurs="unbounded" />
      <xsd:element name="value" type="value" minOccurs="1" maxOccurs="unbounded" />
    </xsd:choice>
    <xsd:attribute name="key" type="xsd:string" use="optional" />
  </xsd:complexType>
</xsd:schema>

1 个答案:

答案 0 :(得分:2)

最后,这是由RHEL5上的 libxml2 的错误版本引起的。

我们注意到我们的服务提供商在升级软件包时重新启动了系统。 libxml2软件包已升级到版本libxml2-2.6.26-2.1.21.el5_9.2,其known serious problems使用包含特定内容的XML模式进行验证。这些问题导致一些XML即使有效也无法通过验证。

问题已在构建libxml2-2.6.26-2.1.22.el5中修复。升级到此版本后,表单再次开始工作。