Bug fix: when the title is empty, use the url as title

This commit is contained in:
Frédéric Guillot 2014-01-11 19:46:30 -05:00
parent b7999ebf5d
commit ad75a71a51
3 changed files with 12 additions and 5 deletions

View File

@ -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)) {

View File

@ -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();
}

View File

@ -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');