Merge remote-tracking branch 'origin/2.7' into 2.8

* origin/2.7:
  #24046 added check for ext-dom to XmlUtil::loadFile
This commit is contained in:
Fabien Potencier 2017-09-04 09:26:37 -07:00
commit 5d2af1ef4c

View File

@ -37,9 +37,14 @@ class XmlUtils
* @return \DOMDocument * @return \DOMDocument
* *
* @throws \InvalidArgumentException When loading of XML file returns error * @throws \InvalidArgumentException When loading of XML file returns error
* @throws \RuntimeException When DOM extension is missing
*/ */
public static function loadFile($file, $schemaOrCallable = null) public static function loadFile($file, $schemaOrCallable = null)
{ {
if (!extension_loaded('dom')) {
throw new \RuntimeException('Extension DOM is required.');
}
$content = @file_get_contents($file); $content = @file_get_contents($file);
if ('' === trim($content)) { if ('' === trim($content)) {
throw new \InvalidArgumentException(sprintf('File %s does not contain valid XML, it is empty.', $file)); throw new \InvalidArgumentException(sprintf('File %s does not contain valid XML, it is empty.', $file));