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

Issue Type: Improvement Created: 2009-09-17T08:26:50.000+0000 Last Updated: 2010-01-01T15:45:54.000+0000 Status: Resolved Fix version(s): - 1.10.0 (27/Jan/10)

Reporter: George Miroshnikov (laggyluke) Assignee: Pádraic Brady (padraic) Tags: - Zend_Feed_Reader

Related issues: Attachments:


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.


Posted by Pádraic Brady (padraic) on 2009-09-17T08:38:57.000+0000

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

Posted by Pádraic Brady (padraic) on 2009-09-19T13:32:21.000+0000

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.

Posted by George Miroshnikov (laggyluke) on 2009-09-19T14:54:55.000+0000

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.

Posted by Pádraic Brady (padraic) on 2009-09-20T06:15:08.000+0000

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.

Posted by George Miroshnikov (laggyluke) on 2009-09-21T06:45:37.000+0000

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.

Posted by Pádraic Brady (padraic) on 2009-09-21T07:28:38.000+0000

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?

<pre class="highlight">
$feeds = Zend_Feed_Reader::findFeedLinks('<a href=""></a>');
$first = $feeds->current();
$firstHref = $first['href']; // <a href=""></a>
$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.

Posted by George Miroshnikov (laggyluke) on 2009-09-21T08:04:51.000+0000

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:

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

Posted by Cristian Bichis (avantis) on 2009-11-26T23:49:44.000+0000


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...

Posted by Pádraic Brady (padraic) on 2009-11-27T02:51:12.000+0000

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?

Posted by Cristian Bichis (avantis) on 2009-11-27T02:59:44.000+0000

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

I am getting only one feed, not multiple feeds.

Posted by Cristian Bichis (avantis) on 2010-01-01T14:28:24.000+0000

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

Posted by Dolf Schimmel (Freeaqingme) (freak) on 2010-01-01T14:33:14.000+0000

Are you on trunk?

Posted by Cristian Bichis (avantis) on 2010-01-01T14:38:45.000+0000


Posted by Pádraic Brady (padraic) on 2010-01-01T15:45:54.000+0000

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.

Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.