Zend Framework

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

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: 0.1.3, 1.7.3
  • Fix Version/s: 1.8.0
  • Component/s: Zend_Feed
  • Labels:
    None
  • Fix Version Priority:
    Should Have

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;
      }
    }
  }
}

Issue Links

Activity

Hide
Bill Karwin added a comment -

Changing fix version to 0.6.0.

Show
Bill Karwin added a comment - Changing fix version to 0.6.0.
Hide
Simone Carletti added a comment -

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

Show
Simone Carletti added a comment - I forgot to say that my previous comment has been inspired by http://www.nabble.com/zend-feed-issue--tf4928553s16154.html#a14108105
Hide
Simone Carletti added a comment -

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

Show
Simone Carletti added a comment - Forgive me for previous comment. It was created for ZF-405, I posted it here by mistake.
Hide
Matthew Turland added a comment -

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";
}

Show
Matthew Turland added a comment - 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"; }
Hide
Simone Carletti added a comment -

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"; }
Show
Simone Carletti added a comment - 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"; }
Hide
Matthew Turland added a comment -

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

Show
Matthew Turland added a comment - 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
Hide
Wil Sinclair added a comment -

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

Show
Wil Sinclair added a comment - Matthew, what is the status of this issue? Do you need someone to apply your patch?
Hide
Matthew Turland added a comment -

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.

Show
Matthew Turland added a comment - 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.
Hide
Benjamin Eberlei added a comment -

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

Show
Benjamin Eberlei added a comment - Applied patch from Matthew in ZF-405, which solves this issues.
Hide
Satoru Yoshida added a comment -

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

Show
Satoru Yoshida added a comment - Sorry, not in 1.7.4. I think it may be released in next minor.

People

Vote (4)
Watch (3)

Dates

  • Created:
    Updated:
    Resolved: