ZF-7870: Zend_Feed_Reader::findFeedLinks() should support multiple feeds


Zend_Feed_Reader::findFeedLinks() supports only one feed per type, but it's perfectly valid for a page to have multiple feeds of the same type. This limitation makes findFeedLinks() almost useless when dealing with arbitrary pages.


Good catch - it's something I already have listed as needed and I'll update this issue as soon as its added.

If there is any specific example of a multi-feed containing page, please let me know here. I'll be implementing this functionality as part of a Zend_Feed_Reader_FeedSet class improvement to encapsulate multiple feeds, and lazy-loading of feed objects.

The only example I can provide right away is in Ukrainian/Russian language: But I'm sure there's more international sites implementing this scenario, so I'll add one when I find.

Implemented, with other changes, in r18318

George, this will reach ZF 1.10, not 1.9, but you can pull the change from trunk and please let me know how this works for you. The manual for Zend_Feed_Reader in trunk has also been updated.

Pádraic, first of all - thanks for your work!

I'm not sure if this is the right place for the discussion, but I'm not sure why FeedSet has that structure - "rss", "rdf" and "atom" properties. Why don't we just return the array of objects implementing Zend_Feed_Reader_FeedInterface (with some kind of lazy-loading, ofcourse)? What's the idea behind trying to link different feed types in a single structure?

BTW, when I try to call findFeedLinks() now, it returns Zend_Feed_Reader_FeedSet containing multiple Zend_Feed_Reader_FeedSet-s - I'm not sure this is intended/good idea.

The object keys are needed (unfortunately) for backwards compatibility - it will be removed in 2.0, which reminds me to mark them deprecated. The preferred interface now is iterating the object, picking whatever feed you wish, and lazy load it using the feed key. Is that what you're doing now?

$feeds = Zend_Feed_Reader::findFeedLinks('');
$first = $feeds->current();
$firstHref = $first['href']; //
$firstRel = $first['rel']; // alternate
$firstType = $first['type']; // application/rss+xml
$firstFeed = $first['feed']; // object: Zend_Feed_Reader_FeedAbstract (lazy loaded)

The new FeedSet type is a simple ArrayObject - it's nested per feed link detected. Perhaps not the finest design around, but adding another object wasn't really needed. I can refactor it a bit before 1.10 is finalised so the sub-objects are a different type.

Oh, thanks, now it all makes perfect sense! The functionality works perfectly, but IMHO the interface is a bit clumsy.

In your example, $feeds is an instance of FeedSet and $first is also an instance of FeedSet. But what we FeedSet actually contains are feed links, not feeds themselves. So, just for example, if we rename FeedSet to FeedLinkSet, then we can have FeedLink-s in it. FeedLinkSet may still extend ArrayObject, but FeedLink should be a standalone class. As a bonus, we get rid of array notation and have proper getters :)

Then we could do things like this:

$feedLinks = Zend_Feed_Reader::findFeedLinks('');
foreach ($feedLinks as $feedLink) {
    $feedHref = $feedLink->getHref();
    $feed = $feedLink->getFeed(); // or import(), or importFeed()... to stress it's lazy-loadness


I can confirm that Zend_Feed_Reader::findFeedLinks doesn't work for multiple feed links on the same page.

For a sample check, has 10 feed links...

While technically resolved, it's being updated for 1.10. The fix is not available for 1.9.x since it may break backwards compatibility (hopefully not) and adds a new return type to handle multiple feeds. Can you confirm the issue exists in a 1.9.x version and not trunk?

Actually i just tested on trunk and doesn't work.

I am getting only one feed, not multiple feeds.

This is not working yet, the status should be changed to UNRESOLVED !

Are you on trunk?


Cristian, this is a three month old issue which was resolved by adding code to trunk for 1.10 a long time ago (1.10 was then in development). The component has since seen refactoring, new features, Zend_Feed_Writer (a whole new component) and some design changes. It's not surprising some less essential improvements are waiting for Beta. This one specifically needs to make use of the newer Zend_Feed_Reader_Collection style ArrayObjects in keeping with the current design changes.

If you want to track its progress, by all means add a new issue ;). However, I won't reopen old issues or keep them open any longer than needed.