Skip to content

[Config] Schema load fails when libxml entity loader is disabled #11258

Closed
@ccorliss

Description

@ccorliss

Config file schemas fail to load under certain scenarios. Below is a sample critical error:

[2014-06-30 06:24:39] request.CRITICAL: Uncaught PHP Exception Symfony\Component\Validator\Exception\MappingException: "[WARNING 1549] failed to load external entity "/var/www/html/.../vendor/symfony/symfony/src/Symfony/Component/Validator/Mapping/Loader/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd" (in n/a - line 0, column 0) [ERROR 1757] Failed to locate the main schema resource at '/var/www/html/.../vendor/symfony/symfony/src/Symfony/Component/Validator/Mapping/Loader/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd'. (in n/a - line 0, column 0)" at /var/www/html/.../vendor/symfony/symfony/src/Symfony/Component/Validator/Mapping/Loader/XmlFileLoader.php line 195 {"exception":"[object] (Symfony\\Component\\Validator\\Exception\\MappingException: [WARNING 1549] failed to load external entity \"/var/www/html/.../vendor/symfony/symfony/src/Symfony/Component/Validator/Mapping/Loader/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd\" (in n/a - line 0, column 0)\n[ERROR 1757] Failed to locate the main schema resource at '/var/www/html/.../vendor/symfony/symfony/src/Symfony/Component/Validator/Mapping/Loader/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd'. (in n/a - line 0, column 0) at /var/www/html/.../vendor/symfony/symfony/src/Symfony/Component/Validator/Mapping/Loader/XmlFileLoader.php:195, InvalidArgumentException: [WARNING 1549] failed to load external entity \"/var/www/html/.../vendor/symfony/symfony/src/Symfony/Component/Validator/Mapping/Loader/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd\" (in n/a - line 0, column 0)\n[ERROR 1757] Failed to locate the main schema resource at '/var/www/html/.../vendor/symfony/symfony/src/Symfony/Component/Validator/Mapping/Loader/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd'. (in n/a - line 0, column 0) at /var/www/html/...

These are two scenarios that will cause this to happen:

  • libxml_disable_entity_loader is explicitly set to true.
  • libxml_disable_entity_loader is expected to be false, but it is set to true due to libxml_disable_entity_loader not being thread safe (see php bug https://bugs.php.net/bug.php?id=64938 ).

libxml_disable_entity_loader prevents libxml from loading even local files. It seems like the most reasonable approach is to read the file contents and load the source, as opposed to the xml packages attempting to load the files themselves.

This also seems to be the standard approach elsewhere:
https://github.com/symfony/symfony/blob/master/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php#L452

This thread has more details on the issue #10493

I'll work on a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions