Merge pull request #23461 from eileenmcnaughton/import_woohoo
[civicrm-core.git] / CRM / Utils / XML.php
index 278ca494c3afb963c41af31d416aaad41c815c27..12eb7a629ee8bd4c7c4bbd25f0a76b8f26c742f8 100644 (file)
@@ -18,7 +18,7 @@ class CRM_Utils_XML {
   /**
    * Read a well-formed XML file
    *
-   * @param $file
+   * @param string $file
    *
    * @return array
    *   (0 => SimpleXMLElement|FALSE, 1 => errorMessage|FALSE)
@@ -36,9 +36,10 @@ class CRM_Utils_XML {
       $oldLibXMLErrors = libxml_use_internal_errors();
       libxml_use_internal_errors(TRUE);
 
-      $xml = simplexml_load_file($file,
-        'SimpleXMLElement', LIBXML_NOCDATA
-      );
+      // Note that under obscure circumstances calling simplexml_load_file
+      // hit https://bugs.php.net/bug.php?id=62577
+      $string = file_get_contents($file);
+      $xml = simplexml_load_string($string, 'SimpleXMLElement', LIBXML_NOCDATA);
       if ($xml === FALSE) {
         $error = self::formatErrors(libxml_get_errors());
       }