From: Andrew Dolgov Date: Sun, 12 Jan 2014 04:53:30 +0000 (+0400) Subject: parser: fix failing on empty media:group tags X-Git-Tag: 1.12~122 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=2ab7ccb695fa690ee56100304b93d20e2c20debc;p=tt-rss.git parser: fix failing on empty media:group tags --- diff --git a/classes/feeditem/atom.php b/classes/feeditem/atom.php index 244fb1f8..74be03d8 100644 --- a/classes/feeditem/atom.php +++ b/classes/feeditem/atom.php @@ -160,19 +160,21 @@ class FeedItem_Atom extends FeedItem_Common { $content = $this->xpath->query("media:content", $enclosure)->item(0); - $enc->type = $content->getAttribute("type"); - $enc->link = $content->getAttribute("url"); - $enc->length = $content->getAttribute("length"); - - $desc = $this->xpath->query("media:description", $content)->item(0); - if ($desc) { - $enc->title = strip_tags($desc->nodeValue); - } else { - $desc = $this->xpath->query("media:description", $enclosure)->item(0); - if ($desc) $enc->title = strip_tags($desc->nodeValue); - } + if ($content) { + $enc->type = $content->getAttribute("type"); + $enc->link = $content->getAttribute("url"); + $enc->length = $content->getAttribute("length"); + + $desc = $this->xpath->query("media:description", $content)->item(0); + if ($desc) { + $enc->title = strip_tags($desc->nodeValue); + } else { + $desc = $this->xpath->query("media:description", $enclosure)->item(0); + if ($desc) $enc->title = strip_tags($desc->nodeValue); + } - array_push($encs, $enc); + array_push($encs, $enc); + } } $enclosures = $this->xpath->query("media:thumbnail", $this->elem); diff --git a/classes/feeditem/rss.php b/classes/feeditem/rss.php index 7d445a6c..28f4a388 100644 --- a/classes/feeditem/rss.php +++ b/classes/feeditem/rss.php @@ -140,19 +140,21 @@ class FeedItem_RSS extends FeedItem_Common { $content = $this->xpath->query("media:content", $enclosure)->item(0); - $enc->type = $content->getAttribute("type"); - $enc->link = $content->getAttribute("url"); - $enc->length = $content->getAttribute("length"); - - $desc = $this->xpath->query("media:description", $content)->item(0); - if ($desc) { - $enc->title = strip_tags($desc->nodeValue); - } else { - $desc = $this->xpath->query("media:description", $enclosure)->item(0); - if ($desc) $enc->title = strip_tags($desc->nodeValue); + if ($content) { + $enc->type = $content->getAttribute("type"); + $enc->link = $content->getAttribute("url"); + $enc->length = $content->getAttribute("length"); + + $desc = $this->xpath->query("media:description", $content)->item(0); + if ($desc) { + $enc->title = strip_tags($desc->nodeValue); + } else { + $desc = $this->xpath->query("media:description", $enclosure)->item(0); + if ($desc) $enc->title = strip_tags($desc->nodeValue); + } + + array_push($encs, $enc); } - - array_push($encs, $enc); } $enclosures = $this->xpath->query("media:thumbnail", $this->elem);