Fix DOMDocument usage on PHP 8.2
[phorkie.git] / src / phorkie / HtmlParser.php
index 38d8af858206627cc15b78e2c680b2ef3a72b225..8102c69a42c6e45d4c79cefb4773dc7ff7926bb7 100644 (file)
@@ -92,11 +92,13 @@ class HtmlParser
         //$sx = simplexml_load_file($url);
 
         libxml_use_internal_errors(true);
+        $domDoc = new \DOMDocument();
         if ($html === null) {
-            $sx = simplexml_import_dom(\DOMDocument::loadHTMLFile($url));
+            $domDoc->loadHTMLFile($url);
         } else {
-            $sx = simplexml_import_dom(\DOMDocument::loadHTML($html));
+            $domDoc->loadHTML($html);
         }
+        $sx = simplexml_import_dom($domDoc);
         //FIXME: handle network error
 
         $elems = $sx->xpath('//*[@rel="vcs-git"]');
@@ -174,6 +176,8 @@ class HtmlParser
     public function getHtmlTitle($url)
     {
         libxml_use_internal_errors(true);
+        //allow loading URLs in DOMDocument
+        libxml_disable_entity_loader(false);
         $doc = \DOMDocument::loadHTMLFile($url);
         if ($doc === false) {
             return null;