From f5c881586bd6eb41036e36625f426c00aa993c4f Mon Sep 17 00:00:00 2001 From: wn_ Date: Sun, 14 Nov 2021 16:59:21 +0000 Subject: [PATCH] Handle potentially null link, title, etc. in FeedParser. --- classes/feedparser.php | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/classes/feedparser.php b/classes/feedparser.php index 05412ef1e..abf1545f8 100644 --- a/classes/feedparser.php +++ b/classes/feedparser.php @@ -11,18 +11,18 @@ class FeedParser { private $libxml_errors = []; /** @var array */ - private $items; + private $items = []; - /** @var string */ + /** @var string|null */ private $link; - /** @var string */ + /** @var string|null */ private $title; - /** @var int */ + /** @var FeedParser::FEED_*|null */ private $type; - /** @var DOMXPath */ + /** @var DOMXPath|null */ private $xpath; const FEED_RDF = 0; @@ -49,8 +49,6 @@ class FeedParser { } } libxml_clear_errors(); - - $this->items = array(); } function init() : void { @@ -208,11 +206,11 @@ class FeedParser { } function get_link() : string { - return clean($this->link); + return clean($this->link ?? ''); } function get_title() : string { - return clean($this->title); + return clean($this->title ?? ''); } /** @return array */