Skip to content

Commit 26ef6d2

Browse files
committed
minor symfony#24047 Added check for ext-dom to XmlUtil::loadFile (oleg-andreyev)
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 | symfony#24046 | License | MIT Commits ------- 2f292c2 symfony#24046 added check for ext-dom to XmlUtil::loadFile
2 parents 9c796b4 + 2f292c2 commit 26ef6d2

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/Symfony/Component/Config/Util/XmlUtils.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,14 @@ private function __construct()
3737
* @return \DOMDocument
3838
*
3939
* @throws \InvalidArgumentException When loading of XML file returns error
40+
* @throws \RuntimeException When DOM extension is missing
4041
*/
4142
public static function loadFile($file, $schemaOrCallable = null)
4243
{
44+
if (!extension_loaded('dom')) {
45+
throw new \RuntimeException('Extension DOM is required.');
46+
}
47+
4348
$content = @file_get_contents($file);
4449
if ('' === trim($content)) {
4550
throw new \InvalidArgumentException(sprintf('File %s does not contain valid XML, it is empty.', $file));

0 commit comments

Comments
 (0)