Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

[Add-on Bug] RSS2 / ATOM Feeds Pagination

dan39dan39 New
edited November 2007 in Vanilla 1.0 Help
The RSS2 and ATOM extensions appear to, literally, create a separate feed for each subsequent page of a discussion, category, search, and all discussions.

For instance, if you navigate to Page 5 of a particular discussion and then you decide to subscribe to the RSS feed for the discussion, you are actually only subscribing to the "Page 5" feed for that discussion. Which means that you are destined to never see the most recent 4 pages at any given time if you rely on that feed to keep you up to date.

Is there an easy way for the RSS and ATOM extension to default to "Page 1" for every feed?

Comments

  • MarkMark Vanilla Staff
    I'm not really sure of the best way to handle this - feel free to step in with your suggestions. The good news is that the feed url is taken from a single function in the rss2/global_functions.php file like so:

    function GetFeedUriForRSS2(&$Configuration, $Parameters) { if ($Configuration['URL_BUILDING_METHOD'] == 'mod_rewrite') $Parameters->Remove('DiscussionID'); $Uri = GetRequestUri(); $Uri = explode('?', $Uri); $Uri = $Uri[0]; return $Uri.'?'.$Parameters->GetQueryString(); }

    If you're not using mod_rewrite, this is an easy fix, you can do it like this:

    function GetFeedUriForRSS2(&$Configuration, $Parameters) { if ($Configuration['URL_BUILDING_METHOD'] == 'mod_rewrite') $Parameters->Remove('DiscussionID'); $Parameters->Remove('page'); $Uri = GetRequestUri(); $Uri = explode('?', $Uri); $Uri = $Uri[0]; return $Uri.'?'.$Parameters->GetQueryString(); }

    But if you ARE using mod_rewrite, you'll have to parse the $Uri to get rid of the page number... which is more of a pain and my sick head can't deal with figuring that out right now...
  • dan39dan39 New
    edited November 2006
    Hmm.. Unfortunately, I am using mod_rewrite. But, even more unfortunate is my inability to parse the $Uri.

    I was only able to figure out a really dirty fix by forcing page 1 at all times like this:

    <?php function GetFeedUriForRSS2(&$Configuration, $Parameters) { if ($Configuration['URL_BUILDING_METHOD'] == 'mod_rewrite') $Parameters->Remove('DiscussionID'); $Parameters->Remove('page'); $Uri = GetRequestUri(); $Uri = explode('?', $Uri); $Uri = $Uri[0]; return $Uri.'?page=1&'.$Parameters->GetQueryString(); } ?>

    My approach seems pretty sloppy, so I'd rather not do it this way if I can help it. Anyone else have any ideas?

    (Get some rest, Mark..!)
  • dan39dan39 New
    edited November 2006
    Anyone know how to parse the URL and strip out the page number the correct way for mod_rewrite? Could really use some help with this.
  • Hi all, the above fix which includes either removing the page-reference or fixing it to page 1 is both fine when you have your newly added comments first. But if you, like this site, have new comments added last in discussions they will never be sent to the feed as the feed only consist of the n first comments. (where n is the number of comments per page in the "Application Settings")
  • MarkMark Vanilla Staff
    Yeah, you need to remove the page number from the url entirely so that the feed can do it's own paging.
  • Well, removing the page from the url sent to the extension won't do any good as the extension only fetches one page of comments. (correct me if I'm wrong!)

    Wrapping the fetcher for the comments using the code below fixed it for me:

    (starting at line 266 in RSS2/default.php, including some unmodified code on the top and bottom for reference)

    // Loop through the data $Feed = ""; $Properties = array(); $PageCount = CalculateNumberOfPages($CommentGrid->CommentDataCount, $CommentGrid->Context->Configuration['COMMENTS_PER_PAGE']); $CommentManager = $CommentGrid->Context->ObjectFactory->NewContextObject( $CommentGrid->Context, 'CommentManager'); $CurrentPage = 1; while ($CurrentPage <= $PageCount) { $CommentGrid->CommentData = $CommentManager->GetCommentList( $CommentGrid->Context->Configuration['COMMENTS_PER_PAGE'], $CurrentPage, $CommentGrid->Discussion->DiscussionID); // Old code for fetching a page of comments. Left untouched. $CurrentPage++; } $Feed = ReturnWrappedFeedForRSS2($CommentGrid->Context, $Feed);
  • dan39dan39 New
    edited November 2006
    Part of the problem is that the Comments pages and the Discussions pages act very differently. On the Comments pages, you want to force the feed to take content from the LAST page. But, on the Discussions pages, the Category pages, and the Search results pages, you just want the FIRST page content.

    ----

    @Jetthe: When I'm implementing this patch, it only seems to fix the individual "comments" pages. But, I'm still seeing the pagination issue on the other pages (i.e. All Comments pages, Category pages, Search results pages).
  • dan39dan39 New
    edited November 2006
    I went through and documented the pagination bug on every page type on the Lussumo Community. To fix this bug, the page number should be stripped for ALL FEEDS. Also the COMMENTS FEED needs to somehow pull in the latest comments no matter which page you subscribe from.

    If anyone can fix the RSS/ATOM Pagination bug (especially w/ mod_rewrite), please chime in.

    EXAMPLES OF THE PROBLEMATIC RSS LINKS:
    --------
    ALL Discussions - Page 1:
    http://lussumo.com/community/?Feed=RSS2
    [CORRECT]

    ALL Discussions - Page 2+:
    http://lussumo.com/community/discussions/2/?Feed=RSS2
    [INCORRECT. Should be same Feed URL as Page 1. (Just strip out page number)]

    --------
    COMMENTS for "The official I hate PCs discussion" - Page 1:
    http://lussumo.com/community/discussion/4242/1/the-official-i-hate-pcs-discussion/?Feed=RSS2
    [INCORRECT. This only gives you the RSS feed for this page. This feed becomes obsolete once the discussion moves on to the next page.]

    COMMENTS for "The official I hate PCs discussion" - Page 2+:
    http://lussumo.com/community/discussion/4242/2/the-official-i-hate-pcs-discussion/?Feed=RSS2
    [INCORRECT. This only gives you the RSS feed for this page. This feed becomes obsolete once the discussion moves on to the next page.]

    --------
    "Random" CATEGORY - Page 1:
    http://lussumo.com/community/10/?CategoryID=10&Feed=RSS2
    [CORRECT]

    "Random" CATEGORY - Page 2+:
    http://lussumo.com/community/10/2/?CategoryID=10&Feed=RSS2
    [INCORRECT. Should be the same Feed URL as Page 1. (Just strip out page number)]

    --------
    SEARCH RESULTS for "php" - Page 1:
    http://lussumo.com/community/search/?PostBackAction=Search&Keywords=php&Type=Topics&btnSubmit=Search&Feed=RSS2
    [CORRECT]

    SEARCH RESULTS for "php" - Page 2+:
    http://lussumo.com/community/search/2/?PostBackAction=Search&Keywords=php&Type=Topics&btnSubmit=Search&Feed=RSS2
    [INCORRECT. Should be the same Feed URL as Page 1. (Just strip out page number)]

    --------
  • dan39dan39 New
    edited December 2006
    It seems the way to fix this is with a combination of Jetthe's patch and the parsing of the URI (for those using mod_rewrite) and removing the page number.

    However... I just found another bug in the RSS feed with friendly URLs. If you subscribe to the RSS feed for this discussion and then click on the Title link (which should take you back to this discussion), it gives you a non-friendly URL that fails.

    Mark, any chance you have time to update the RSS and ATOM Add-ons to fix these nasty bugs for everyone?
  • [bump]
  • edited September 2007
    ===sorry, wrong entry=== how can I delete that comment ?
  • edited November 2007
    (at time of writing, #12 in thread is [a worthy member] asking how to delete his post, #13 is [another worthy member]: AFAIK you can't, & this is #14.) First Worthy Member - change it to a whisper to yourself. Nov 11: Alright, WM2!
This discussion has been closed.