Issues

ZF-26: Zend_Feed doesn't read entries not in the channel element (TRAC#7)

Description

After running into this problem in my own feed class, I tried the Zend version out to try to figure out the problem. Turns out it's from entry items NOT being in the channel element. See this feed for an example: http://feeds.feedburner.com/37signals/beMH

Here's my quick and dirty solution:


protected function _buildEntryCache()
{
  $this->_entries = array();
  foreach ($this->_element->childNodes as $child) {
    if ($child->localName == $this->_entryElementName) {
      $this->_entries[] = $child;
    }
  }

    // Added this.
  if (count($this->_entries) == 0) {
    foreach ($this->_element->parentNode->childNodes as $child) {
      if ($child->localName == $this->_entryElementName) {
        $this->_entries[] = $child;
      }
    }
  }
}

Comments

Changing fix version to 0.6.0.

I forgot to say that my previous comment has been inspired by http://nabble.com/zend-feed-issue--tf4928553s16154…

Forgive me for previous comment. It was created for ZF-405, I posted it here by mistake.

The following example appears to work as expected as of SVN revision 7745:

require_once 'Zend/Feed.php';

$feed = Zend_Feed::import('http://feeds.feedburner.com/37signals/beMH');

foreach ($feed as $item) { echo 'title: ', $item->title(), "\n"; echo 'link: ', $item->link(), "\n\n"; }

The issue still exists. The reason why you wasn't able to reproduce it is just because the feed you tested is no longer an RSS feed but it's now served as Atom feed and Zend_Feed correctly supports Atom feeds.

Have a look at the following example:


require_once 'Zend/Feed.php';

$feed = Zend_Feed::import('http://maine.craigslist.org/web/index.rss');

foreach ($feed as $item) { echo 'title: ', $item->title(), "\n"; echo 'link: ', $item->link(), "\n\n"; }

Please see the attachment patch.diff for ZF-405. This appears to correct this issue.

For the particular feed cited below, something I noticed that wasn't the case for ZF-405 is that there are two title attributes per item, title and dc:title, and the returned Zend_Feed_Rss object reflects this. I'm not sure if this should be considered a "feature" or a "bug" being that, in most cases, the two elements have the same value anyway.

http://maine.craigslist.org/web/index.rss

Matthew, what is the status of this issue? Do you need someone to apply your patch?

Wil, I've updated ZF-405 with a new version of the patch. It does not modify the suggested change to Zend_Feed_Rss::__wakeup (which still works), but updates the unit tests in a way that I think will be more agreeable to other developers. But yes, I don't believe I have the access needed to commit the patch myself, so it will need to be committed by someone else.

Applied patch from Matthew in ZF-405, which solves this issues.

Sorry, not in 1.7.4. I think it may be released in next minor.