From ad75a71a51a42c6df11a68520bcfd7a62239cb4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Guillot?= Date: Sat, 11 Jan 2014 19:46:30 -0500 Subject: [PATCH] Bug fix: when the title is empty, use the url as title --- vendor/PicoFeed/Parsers/Atom.php | 5 ++++- vendor/PicoFeed/Parsers/Rss10.php | 7 ++++--- vendor/PicoFeed/Parsers/Rss20.php | 5 ++++- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/vendor/PicoFeed/Parsers/Atom.php b/vendor/PicoFeed/Parsers/Atom.php index 31583f5..30dd2f3 100644 --- a/vendor/PicoFeed/Parsers/Atom.php +++ b/vendor/PicoFeed/Parsers/Atom.php @@ -18,11 +18,14 @@ class Atom extends \PicoFeed\Parser } $this->url = $this->getUrl($xml); - $this->title = $this->stripWhiteSpace((string) $xml->title); + $this->title = $this->stripWhiteSpace((string) $xml->title) ?: $this->url; $this->id = (string) $xml->id; $this->updated = $this->parseDate((string) $xml->updated); $author = (string) $xml->author->name; + \PicoFeed\Logging::log(\get_called_class().': Title => '.$this->title); + \PicoFeed\Logging::log(\get_called_class().': Url => '.$this->url); + foreach ($xml->entry as $entry) { if (isset($entry->author->name)) { diff --git a/vendor/PicoFeed/Parsers/Rss10.php b/vendor/PicoFeed/Parsers/Rss10.php index b6890e7..d4b6ccf 100644 --- a/vendor/PicoFeed/Parsers/Rss10.php +++ b/vendor/PicoFeed/Parsers/Rss10.php @@ -19,17 +19,18 @@ class Rss10 extends \PicoFeed\Parser $namespaces = $xml->getNamespaces(true); - $this->title = $this->stripWhiteSpace((string) $xml->channel->title); + $this->title = $this->stripWhiteSpace((string) $xml->channel->title) ?: $this->url; $this->url = (string) $xml->channel->link; $this->id = $this->url; - if (isset($namespaces['dc'])) { + \PicoFeed\Logging::log(\get_called_class().': Title => '.$this->title); + \PicoFeed\Logging::log(\get_called_class().': Url => '.$this->url); + if (isset($namespaces['dc'])) { $ns_dc = $xml->channel->children($namespaces['dc']); $this->updated = isset($ns_dc->date) ? $this->parseDate($ns_dc->date) : time(); } else { - $this->updated = time(); } diff --git a/vendor/PicoFeed/Parsers/Rss20.php b/vendor/PicoFeed/Parsers/Rss20.php index 8196b30..86eff74 100644 --- a/vendor/PicoFeed/Parsers/Rss20.php +++ b/vendor/PicoFeed/Parsers/Rss20.php @@ -37,10 +37,13 @@ class Rss20 extends \PicoFeed\Parser $this->url = (string) $xml->channel->link; } - $this->title = $this->stripWhiteSpace((string) $xml->channel->title); + $this->title = $this->stripWhiteSpace((string) $xml->channel->title) ?: $this->url; $this->id = $this->url; $this->updated = $this->parseDate(isset($xml->channel->pubDate) ? (string) $xml->channel->pubDate : (string) $xml->channel->lastBuildDate); + \PicoFeed\Logging::log(\get_called_class().': Title => '.$this->title); + \PicoFeed\Logging::log(\get_called_class().': Url => '.$this->url); + // RSS feed might be empty if (! $xml->channel->item) { \PicoFeed\Logging::log(\get_called_class().': feed empty or malformed');