Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Merged

Conversation

@oleg-andreyev
Copy link
Contributor

@oleg-andreyevoleg-andreyev commentedAug 31, 2017
edited by ogizanagi
Loading

QA
Branch?2.7
Bug fix?no, minor enhancement to gracefully suggest to installext-dom if missing when trying to useXmlUtil::loadFile
New feature?no
BC breaks?no
Deprecations?no
Tests pass??
Fixed tickets#24046
LicenseMIT

],
"require": {
"php":"^7.1.3",
"ext-dom":"*",
Copy link
ContributorAuthor

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 $? // => 0

@xabbuh
Copy link
Member

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 theXmlUtils class instead.

@oleg-andreyevoleg-andreyevforce-pushed theadd-dom-extension-to-composer branch fromf665f42 to6e18095CompareAugust 31, 2017 10:04
@oleg-andreyev
Copy link
ContributorAuthor

@xabbuh I've added extension check toloadFile only, becauselibxml is required byphp7.1 ,convertDomElementToArray has argument with instanceof\DOMElement

@stof
Copy link
Member

FrameworkBundle should have the requirement though, because it depends on XML support.

@stof
Copy link
Member

the requirement should beext-dom btw

@oleg-andreyev
Copy link
ContributorAuthor

@stofext-xml requirements was added in#22676 and as@xabbuh mentioned it's valid use case to usesymfony/config withoutext-xml orext-dom

@chalasr
Copy link
Member

What@stof means is that the requirement on FrameworkBundle should beext-dom instead ofext-xml, that could be fixed here if you wish to do it.
For Config, we should just throw in XmlUtiils if!extension_loaded('xml') as suggested by@xabbuh .

@chalasr
Copy link
Member

Btw, this should be rebased on 2.7 and the target branch changed accordingly.

@chalasrchalasr added this to the2.7 milestoneAug 31, 2017
@oleg-andreyev
Copy link
ContributorAuthor

@chalasr it's possible to disable xml and enable dom only, ref.:#24047 (comment), so changing FrameworkBundle requirements fromext-xml toext-dom is quite dangerous

I can put!extension_loaded('dom') in the file, but I didn't done that initially because\Symfony\Component\Config\Util\XmlUtils::phpize is quite useful method :)

@stof
Copy link
Member

@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
Copy link
Member

chalasr commentedAug 31, 2017
edited
Loading

For Config we should deal withxml only, notdom which is a requirement for FrameworkBundle only. So the check should be!extension_loaded('xml').

I didn't done that initially because \Symfony\Component\Config\Util\XmlUtils::phpize is quite useful method :)

Well, I don't have the code in mind, but ifphpize() can be used without thexml extension, we should not forbid using it, adding the check only where it breaks already ifxml extension not loaded. But I guess it does break, isn't it?

edit: let's let FrameworkBundle as is ifdom doesn't guaranteexml, as said

@oleg-andreyev
Copy link
ContributorAuthor

@chalasr I don't see whereext-dom in requirements for FrameworkBundle.

sum up:

  • I've updatedXmlUtils::loadFile because it's using\DOMDocument
  • I didn't updateXmlUtils::phpize could be used withoutext-xml orext-dom
  • I didn't updateXmlUtils::convertDomElementToArray, because it has input argument\DOMElement $element

@oleg-andreyevoleg-andreyevforce-pushed theadd-dom-extension-to-composer branch from6e18095 to8bde9e2CompareAugust 31, 2017 13:56
@oleg-andreyevoleg-andreyev changed the base branch frommaster to2.7August 31, 2017 13:56
*/
publicstaticfunctionloadFile($file,$schemaOrCallable =null)
{
if (!extension_loaded('dom')) {
Copy link
Member

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?

Copy link
ContributorAuthor

@oleg-andreyevoleg-andreyevAug 31, 2017
edited
Loading

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-pear

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

ok then :)

@chalasr
Copy link
Member

chalasr commentedAug 31, 2017
edited
Loading

The existing tests for this method should be updated to add@requires extension dom (and/or xml) so that the component test suite can be ran even if the extension is not loaded.

@oleg-andreyev
Copy link
ContributorAuthor

add@requires extension dom

@chalasr I'm a bit surprised, but withoutext-dom we won't be able to run phpunit
Ref.:\PHPUnit\Util\Xml::load, lol

@chalasr
Copy link
Member

@oleg-andreyev fair enough 😅

@chalasr
Copy link
Member

@oleg-andreyev Can you rebase your branch against 2.7 to see tests green?

@ogizanagiogizanagiforce-pushed theadd-dom-extension-to-composer branch from8bde9e2 to2f292c2CompareSeptember 3, 2017 10:03
@ogizanagiogizanagi changed the titleadding ext-xml to symfony/configAdded check for ext-dom to XmlUtil::loadFileSep 3, 2017
@ogizanagi
Copy link
Contributor

Thank you@oleg-andreyev.

@ogizanagiogizanagi merged commit2f292c2 intosymfony:2.7Sep 3, 2017
ogizanagi added a commit that referenced this pull requestSep 3, 2017
…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
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@chalasrchalasrchalasr approved these changes

+1 more reviewer

@ogizanagiogizanagiogizanagi approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

2.7

Development

Successfully merging this pull request may close these issues.

6 participants

@oleg-andreyev@xabbuh@stof@chalasr@ogizanagi@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp