deal with several DOMElement-related errors

This commit is contained in:
Andrew Dolgov 2021-11-15 08:26:02 +03:00
parent a92070da06
commit aa924d9ee7
5 changed files with 9 additions and 5 deletions

View File

@ -602,6 +602,7 @@ class Article extends Handler_Protected {
} else if ($e->nodeName == "video") { } else if ($e->nodeName == "video") {
$article_image = $e->getAttribute("poster"); $article_image = $e->getAttribute("poster");
/** @var DOMElement|false $src */
$src = $tmpxpath->query("//source[@src]", $e)->item(0); $src = $tmpxpath->query("//source[@src]", $e)->item(0);
if ($src) { if ($src) {

View File

@ -65,10 +65,12 @@ class FeedParser {
$this->xpath = $xpath; $this->xpath = $xpath;
$root = $xpath->query("(//atom03:feed|//atom:feed|//channel|//rdf:rdf|//rdf:RDF)"); $root_list = $xpath->query("(//atom03:feed|//atom:feed|//channel|//rdf:rdf|//rdf:RDF)");
if (!empty($root) && $root->length > 0) { if (!empty($root_list) && $root_list->length > 0) {
$root = $root->item(0);
/** @var DOMElement|false $root */
$root = $root_list->item(0);
if ($root) { if ($root) {
switch (mb_strtolower($root->tagName)) { switch (mb_strtolower($root->tagName)) {

View File

@ -32,7 +32,7 @@ class Af_Comics_ComicPress extends Af_ComicFilter {
return true; return true;
} }
// buni-specific /** @var DOMElement|false $webtoon_link (buni specific) */
$webtoon_link = $xpath->query("//a[contains(@href,'www.webtoons.com')]")->item(0); $webtoon_link = $xpath->query("//a[contains(@href,'www.webtoons.com')]")->item(0);
if ($webtoon_link) { if ($webtoon_link) {

View File

@ -22,7 +22,7 @@ class Af_Comics_Dilbert extends Af_ComicFilter {
if ($res && $doc->loadHTML($res)) { if ($res && $doc->loadHTML($res)) {
$xpath = new DOMXPath($doc); $xpath = new DOMXPath($doc);
// Get the image container /** @var DOMElement|false $basenode (image container) */
$basenode = $xpath->query('(//div[@class="img-comic-container"]/a[@class="img-comic-link"])')->item(0); $basenode = $xpath->query('(//div[@class="img-comic-container"]/a[@class="img-comic-link"])')->item(0);
// Get the comic title // Get the comic title

View File

@ -50,6 +50,7 @@ class Af_Comics_Gocomics extends Af_ComicFilter {
if (@$doc->loadHTML($body)) { if (@$doc->loadHTML($body)) {
$xpath = new DOMXPath($doc); $xpath = new DOMXPath($doc);
/** @var DOMElement|false $node */
$node = $xpath->query('//picture[contains(@class, "item-comic-image")]/img')->item(0); $node = $xpath->query('//picture[contains(@class, "item-comic-image")]/img')->item(0);
if ($node) { if ($node) {