From f85d72256749ec6a947b3552d5d45c71dc0317da Mon Sep 17 00:00:00 2001 From: Garion Herman Date: Fri, 23 Oct 2020 14:51:03 +1300 Subject: [PATCH] Disable libxml_disable_entity_loader() in PHP 8 This method is deprecated in PHP 8, as it is no longer necessary. --- src/Utils.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Utils.php b/src/Utils.php index eb93cd7d..e7dd6aec 100644 --- a/src/Utils.php +++ b/src/Utils.php @@ -274,7 +274,11 @@ public static function xpathQuery(DOMDocument $document, $query, $returnFirst = public static function parse($html) { $errors = libxml_use_internal_errors(true); - $entities = libxml_disable_entity_loader(true); + + // PHP 8 deprecates libxml_disable_entity_loader() as it is no longer needed + if (\PHP_VERSION_ID < 80000) { + $entities = libxml_disable_entity_loader(true); + } $html = trim(self::normalize($html)); @@ -282,7 +286,10 @@ public static function parse($html) $document->loadHTML($html); libxml_use_internal_errors($errors); - libxml_disable_entity_loader($entities); + + if (\PHP_VERSION_ID < 80000) { + libxml_disable_entity_loader($entities); + } return $document; }