From 6498f6122c2575512638230d07079edf7313a922 Mon Sep 17 00:00:00 2001 From: eileen Date: Tue, 4 Feb 2020 20:26:58 +1300 Subject: [PATCH] Fix obscure bug After upgrading to MacOS Catalina & MAMP 5.6 (latest) with php version 7.4.1 or 7.3.9 my site was unable to load CiviCRM with a segfault error. I traced it to this line & found that phpstorm was highlighting the line it red as possibly subject to https://bugs.php.net/bug.php?id=62577 - taking phpstorm's recommendation allowed the site to load - the failure had been on parsing info.xml files --- CRM/Utils/XML.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/CRM/Utils/XML.php b/CRM/Utils/XML.php index 278ca494c3..47619c1c6a 100644 --- a/CRM/Utils/XML.php +++ b/CRM/Utils/XML.php @@ -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()); } -- 2.25.1