Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

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

Closed
ccorliss opened this issue Jun 30, 2014 · 0 comments
Closed

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

ccorliss opened this issue Jun 30, 2014 · 0 comments

Comments

@ccorliss
Copy link
Contributor

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.

fabpot added a commit that referenced this issue Jul 1, 2014
…sable_entity_loader usage (ccorliss)

This PR was submitted for the 2.4 branch but it was merged into the 2.3 branch instead (closes #11259).

Discussion
----------

[Config] Fixed failed config schema loads due to libxml_disable_entity_loader usage

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #11258
| License       | MIT
| Doc PR        | N/A

PR #10493 helped this issue, but it can still affect users that:

1.  Have libxml_disable_entity_loader set to true by default.
2.  Experience libxml_disable_entity_loader php bug https://bugs.php.net/bug.php?id=64938

I used the same approach used in the DI xml validation.
https://github.com/symfony/symfony/blob/master/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php#L452

Commits
-------

de2bef5 Fixed failed config schema loads due to libxml_disable_entity_loader usage.
@fabpot fabpot closed this as completed Jul 1, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants