Skip to content

Commit

Permalink
php 8 compatibility in Zend_Xml_Security class
Browse files Browse the repository at this point in the history
  • Loading branch information
karyna-t committed Sep 10, 2021
1 parent 3f2af6c commit c5206c6
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions library/Zend/Xml/Security.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,10 @@ public static function scan($xml, DOMDocument $dom = null)
}

if (!self::isPhpFpm()) {
$loadEntities = libxml_disable_entity_loader(true);
if (LIBXML_VERSION < 20900) {
// this function no longer has an effect in PHP 8.0, but it's required in earlier versions
$loadEntities = libxml_disable_entity_loader(true);
}
$useInternalXmlErrors = libxml_use_internal_errors(true);
}

Expand All @@ -97,7 +100,9 @@ public static function scan($xml, DOMDocument $dom = null)
if (!$result) {
// Entity load to previous setting
if (!self::isPhpFpm()) {
libxml_disable_entity_loader($loadEntities);
if (isset($loadEntities)) {
libxml_disable_entity_loader($loadEntities);
}
libxml_use_internal_errors($useInternalXmlErrors);
}
return false;
Expand All @@ -117,7 +122,9 @@ public static function scan($xml, DOMDocument $dom = null)

// Entity load to previous setting
if (!self::isPhpFpm()) {
libxml_disable_entity_loader($loadEntities);
if (isset($loadEntities)) {
libxml_disable_entity_loader($loadEntities);
}
libxml_use_internal_errors($useInternalXmlErrors);
}

Expand Down

0 comments on commit c5206c6

Please sign in to comment.