dependency-injection - Spaces in system temp folder path cause deprecation errors in php 8 about libxml_disable_entity_loader · Issue #46799 · symfony/symfony · GitHub
You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<?phprequire_once'vendor/autoload.php';
$containerBuilder = new \Symfony\Component\DependencyInjection\ContainerBuilder();
$loader = new \Symfony\Component\DependencyInjection\Loader\XmlFileLoader($containerBuilder, new \Symfony\Component\Config\FileLocator(__DIR__));
$loader->load('x.xml');
Using php8, run your php file.
PHP Deprecated: Function libxml_disable_entity_loader() is deprecated in ...\vendor\symfony\dependency-injection\Loader\XmlFileLoader.php
I admit I haven't run it against 6.x. Where this came up in real life was in a 3rd party web app that uses version 4.4 of symfony/dependency-injection, but the code is the same as 6.x.
The text was updated successfully, but these errors were encountered:
… in php 8 (demeritcowboy)
This PR was merged into the 4.4 branch.
Discussion
----------
Spaces in system temp folder path cause deprecation errors in php 8
| Q | A
| ------------- | ---
| Branch? | 4.4
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets | Fix#46799
| License | MIT
| Doc PR |
See #46799
Commits
-------
2ac82ac Spaces in system temp folder path cause deprecation errors in php 8
Uh oh!
There was an error while loading. Please reload this page.
Symfony version(s) affected
4.4+
Description
In https://github.com/symfony/dependency-injection/blob/ffaa7b47a728b8a644ced7dce6e3f7b89b1c06bb/Loader/XmlFileLoader.php#L686, it creates a
file://
url that isn't url-encoded. This causes shouldEnableEntityLoader() to return true in php 8 instead of false when e.g. the temp folder path contains spaces.How to reproduce
C:\Users\Your Name\AppData\Local\Temp
. If you don't have that or control over the system temp folder path, then you can temporarily edit https://github.com/symfony/dependency-injection/blob/ffaa7b47a728b8a644ced7dce6e3f7b89b1c06bb/Loader/XmlFileLoader.php#L680 to set $tmpfile to a path that you know exists and has spaces.x.xml
like this:PHP Deprecated: Function libxml_disable_entity_loader() is deprecated in ...\vendor\symfony\dependency-injection\Loader\XmlFileLoader.php
Possible Solution
Patch to https://github.com/symfony/dependency-injection/blob/ffaa7b47a728b8a644ced7dce6e3f7b89b1c06bb/Loader/XmlFileLoader.php#L686:
Additional Context
I admit I haven't run it against 6.x. Where this came up in real life was in a 3rd party web app that uses version 4.4 of symfony/dependency-injection, but the code is the same as 6.x.
The text was updated successfully, but these errors were encountered: