Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
Added check for ext-dom to XmlUtil::loadFile#24047
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
3f45aee tof665f42Compare| ], | ||
| "require": { | ||
| "php":"^7.1.3", | ||
| "ext-dom":"*", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
although DOM is installed together withphp-xml, it's still possible to disablexml extension and enabledom extension
// test.php<?phpuse Symfony\Component\Config\Util\XmlUtils;require_once 'vendor/autoload.php';var_dump(XmlUtils::loadFile('test.xml'));// test.xml<?xml version="1.0" encoding="utf-8"?><root xmlns="http://example.com/schema"></root>$ php -n -dextension=phar.so -dextension=json.so -dextension=iconv.so -dextension=xml.so test.phpFatal error: Uncaught Error: Class 'DOMDocument' not found in /mnt/c/checkouts/symfony/src/Symfony/Component/Config/Util/XmlUtils.php:52$ echo $? # => 255$ php -n -dextension=phar.so -dextension=json.so -dextension=iconv.so -dextension=dom.so test.php$ echo $? // => 0xabbuh commentedAug 31, 2017
It's perfectly valid to use the Config component without XML files. Thus I suggest to instead handle the missing XML extension case gracefully in the |
f665f42 to6e18095Compareoleg-andreyev commentedAug 31, 2017
@xabbuh I've added extension check to |
stof commentedAug 31, 2017
FrameworkBundle should have the requirement though, because it depends on XML support. |
stof commentedAug 31, 2017
the requirement should be |
oleg-andreyev commentedAug 31, 2017
chalasr commentedAug 31, 2017
chalasr commentedAug 31, 2017
Btw, this should be rebased on 2.7 and the target branch changed accordingly. |
oleg-andreyev commentedAug 31, 2017
@chalasr it's possible to disable xml and enable dom only, ref.:#24047 (comment), so changing FrameworkBundle requirements from I can put |
stof commentedAug 31, 2017
@oleg-andreyev the question is whether we need only ext-dom or also ext-xml. If we need ext-xml, the requirement should stay like that. But anyway, for the config component, it must stay an optional dependency (the component contains many other things not requiring XML) |
chalasr commentedAug 31, 2017 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
For Config we should deal with
Well, I don't have the code in mind, but if edit: let's let FrameworkBundle as is if |
oleg-andreyev commentedAug 31, 2017
@chalasr I don't see where sum up:
|
6e18095 to8bde9e2Compare| */ | ||
| publicstaticfunctionloadFile($file,$schemaOrCallable =null) | ||
| { | ||
| if (!extension_loaded('dom')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
you pointed out thatdom doesn't guaranteexml. Should we put|| !extension_loaded('xml') since this is calling xml functions?
oleg-andreyevAug 31, 2017 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
yes,ext-dom does not guarantee thatext-xml is enabled, but php itself guaranteeslibxml, so alllibxml_* will work, unless php is compiled from source with--disable-libxml (which is probably where uncommon)
$ apt-cache depends php7.0-fpmphp7.0-fpm Depends: libmagic1 Depends: mime-support Depends: php7.0-cli Depends: php7.0-common Depends: php7.0-json Depends: php7.0-opcache Depends: tzdata Depends: ucf Depends: init-system-helpers Depends: lsb-base Depends: libapparmor1 Depends: libc6 Depends: libpcre3 Depends: libssl1.0.0 Depends: libsystemd0 Depends: libxml2 Depends: zlib1g Conflicts: <php5-fpm> Suggests: php-pear$ apt-cache depends php7.0-cliphp7.0-cli Depends: libedit2 Depends: libmagic1 Depends: mime-support Depends: php7.0-common Depends: php7.0-json Depends: php7.0-opcache Depends: php7.0-readline Depends: tzdata Depends: ucf Depends: libc6 Depends: libpcre3 Depends: libssl1.0.0 Depends: libxml2 Depends: zlib1g Breaks: <php5-cli> Suggests: php-pear Replaces: <php5-cli>$ apt-cache depends php7.0-cgiphp7.0-cgi Depends: libmagic1 Depends: mime-support Depends: php7.0-cli Depends: php7.0-common Depends: php7.0-json Depends: php7.0-opcache Depends: tzdata Depends: ucf Depends: libc6 Depends: libpcre3 Depends: libssl1.0.0 Depends: libxml2 Depends: zlib1g Conflicts: <php5-cgi> Suggests: php-pearThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
ok then :)
chalasr commentedAug 31, 2017 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
The existing tests for this method should be updated to add |
oleg-andreyev commentedSep 1, 2017
chalasr commentedSep 1, 2017
@oleg-andreyev fair enough 😅 |
chalasr commentedSep 2, 2017
@oleg-andreyev Can you rebase your branch against 2.7 to see tests green? |
8bde9e2 to2f292c2Compareogizanagi commentedSep 3, 2017
Thank you@oleg-andreyev. |
…yev)This PR was merged into the 2.7 branch.Discussion----------Added check for ext-dom to XmlUtil::loadFile| Q | A| ------------- | ---| Branch? | 2.7| Bug fix? | no, minor enhancement to gracefully suggest to install `ext-dom` if missing when trying to use `XmlUtil::loadFile`| New feature? | no| BC breaks? | no| Deprecations? | no| Tests pass? | ?| Fixed tickets |#24046| License | MITCommits-------2f292c2#24046 added check for ext-dom to XmlUtil::loadFile
Uh oh!
There was an error while loading.Please reload this page.
ext-domif missing when trying to useXmlUtil::loadFile