wrong selection when generating RSS feeds for categories/aut

Random stuff about serendipity. Discussion, Questions, Paraphernalia.
Post Reply
secu
Regular
Posts: 14
Joined: Sun May 30, 2010 7:35 am

wrong selection when generating RSS feeds for categories/aut

Post by secu »

Hello experts,

new to this forum and using S9Y for while now but recently I faced an issue I got stuck with:

I use 2 types of selections of entries in a sidebar and both types are used for frontend visitors as well as for the RSS feed offer.
These types are
a) entries by categories
b) entries by authors

Both work fine for people just clicking on the sidebar links to get an entry selection in the middle column, but also both fail with the selection when they try to get the selected content as an RSS feed.

Example:
Clicking on the frontend link for category "cat1" delivers only the entries assigned to "cat1". Correct, works nice. But when clicking on the the RSS feed icon for "cat1" the feed contains ALL entries of the blog (no selection done).

Both links for one category look okay, but only the frontend selection link works while always the RSS feed link delivers the whole content of all entries. Selection by categories and by authors works/fails likewise.

Here are the links for the category based selection as generated (pattern):
frontend selection link: http://www.domain.org/string1-categories/1-catname
rss feed selection link: http://www.domain.org/feeds/categories/1-catname.rss

Here are the links for the author based selection as generated (pattern):
frontend selection link: http://www.domain.org/string1-authors/2-realname
rss feed selection link: http://www.domain.org/feeds/authors/2-realname.rss

These get generated following the settings in configuration. No prob at this point.
Just the selection for RSS Links doesn't work.

What could be wrong ?

Thanks in advance !
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: wrong selection when generating RSS feeds for categories/aut

Post by garvinhicking »

Hi!

Yes! The RSS-Feed sidebar plugin is "content unaware". It always points to the central RSS feed. Chances would be that people read a specific category of your blog but want to subscribe to your blog, and maybe wouldn't recognize that they would then only subscribe to the category's rss feed.

What I suggest you to do is to use both the "Authors" and "Categories" sidebar plugins, which all offer RSS-Feed links to each specific author and category.

HTH,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
secu
Regular
Posts: 14
Joined: Sun May 30, 2010 7:35 am

Re: wrong selection when generating RSS feeds for categories/aut

Post by secu »

garvinhicking wrote:What I suggest you to do is to use both the "Authors" and "Categories" sidebar plugins, which all offer RSS-Feed links to each specific author and category.
Good morning Garvin,
thank you very much for helping, but you got me wrong.

I already use the sidebar plugins you mentioned and the issue is with the RSS links displayed there (within those sidebar boxes). These RSS links are the ones, not working how they probably should.

To clarify: All links (the URIs) get generated according to configuration settings but only the links to browse the frontend deliver selected entries. All RSS links instead look like they were generated right but nonetheless they always deliver unselected content (all entries).

I already digged into everything I could find regarding this but still got no clue what could be wrong there.

Thanks in advance again
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: wrong selection when generating RSS feeds for categories/aut

Post by garvinhicking »

Hi!

Please give me the actual URL, so I can have a look.

It might be related to your permalinks/URL rewriting.

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
secu
Regular
Posts: 14
Joined: Sun May 30, 2010 7:35 am

Re: wrong selection when generating RSS feeds for categories/aut

Post by secu »

Garvin,

I use these event plugins:
- HTML META-Tags
- Sitemap Generator (XML Sitemaps)
- Microblogging
- User Profiles
- My Mood
- Karma
- Polls
- Static Pages

... but the issue with the RSS Links already occured before most of these plugins were installed.

And yes, I use mod_rewrite.

Thanks again for helping
and btw, I really love Serendipity !
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: wrong selection when generating RSS feeds for categories/aut

Post by garvinhicking »

Hi!

Hm, that's really odd. None of those plugins should actually interfere here, you are right.

Tomorrow I'l try to post you a code that will help us in debugging. It seems the $serendipity['GET']['category'] variable is not properly evaluated inside the rss.php file, and we'll need to see why this could happen.

In some cases, the URL parsing might not work when mod_rewrite does not properly forward all elements to $_SERVER['REQUEST_URI'].

Best regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: wrong selection when generating RSS feeds for categories/aut

Post by garvinhicking »

Hi!

Okay, so here we go.

Inside your .htaccess you should have a line like this:

Code: Select all

RewriteRule ^(feeds/categories/[0-9a-z\.\_!;,\+\-\%]+\.rss) index.php?/$1 [NC,L,QSA]
This is the rule that should match due to your permalink setup. To check if that rule works, you could modify it to:

Code: Select all

RewriteRule ^(feeds/categories/[0-9a-z\.\_!;,\+\-\%]+\.rss) test.php?/$1 [NC,L,QSA]
then create a test.php file with a simple "Hello world", and then try to call your RSS feed to see if it redirects there.

If that properly works, revert the change and we'll take on the index.php file next. Inside that file at around line 325 you should see:

Code: Select all

} elseif (preg_match(PAT_PERMALINK_FEEDCATEGORIES, $uri, $matches) || preg_match(PAT_PERMALINK_FEEDAUTHORS, $uri, $matches) || preg_match(PAT_FEEDS, $uri)) {
to test if the RSS feed properly leads there, you can modify it to:

Code: Select all

} elseif (preg_match(PAT_PERMALINK_FEEDCATEGORIES, $uri, $matches) || preg_match(PAT_PERMALINK_FEEDAUTHORS, $uri, $matches) || preg_match(PAT_FEEDS, $uri)) {
die('Hello world - RSS feed contents here');
and then save, test the RSS feed URL again and see.

If that also shows the proper output, the next step is to see why the category is not shown. For that, this code exists:

Code: Select all

    if (is_array($matches)) {
        if (preg_match('@(/?' . preg_quote(PATH_FEEDS, '@') . '/)(.+)\.rss@i', $uri, $uriparts)) {
            if (strpos($uriparts[2], $serendipity['permalinkCategoriesPath']) === 0) {
                $catid = serendipity_searchPermalink($serendipity['permalinkFeedCategoryStructure'], $uriparts[2], $matches[1], 'category');
                if (is_numeric($catid) && $catid > 0) {
                    $_GET['category'] = $catid;
                }
            } elseif (strpos($uriparts[2], $serendipity['permalinkAuthorsPath']) === 0) {
                $authorid = serendipity_searchPermalink($serendipity['permalinkFeedAuthorStructure'], $uriparts[2], $matches[1], 'author');
                if (is_numeric($authorid) && $authorid > 0) {
                    $_GET['viewAuthor'] = $authorid;
                }
            }
        }
    }
change that to:

Code: Select all

print_r($matches);
echo "PATTERN: " . PATH_FEEDS . "<br />\n";
echo "URI: " . $uri . "<br />\n";
echo "PAT: " . $serendipity['permalinkCategoriesPath'] . "<br />\n";
echo "PAT2: " . $serendipity['permalinkFeedCategoryStructure'] . "<br />\n";

if (is_array($matches)) {
    if (preg_match('@(/?' . preg_quote(PATH_FEEDS, '@') . '/)(.+)\.rss@i', $uri, $uriparts)) {
        print_r($uriparts);
        if (strpos($uriparts[2], $serendipity['permalinkCategoriesPath']) === 0) {
            $catid = serendipity_searchPermalink($serendipity['permalinkFeedCategoryStructure'], $uriparts[2], $matches[1], 'category');
            print_r($catid);
            if (is_numeric($catid) && $catid > 0) {
                $_GET['category'] = $catid;
            }
        } elseif (strpos($uriparts[2], $serendipity['permalinkAuthorsPath']) === 0) {
            $authorid = serendipity_searchPermalink($serendipity['permalinkFeedAuthorStructure'], $uriparts[2], $matches[1], 'author');
            if (is_numeric($authorid) && $authorid > 0) {
                $_GET['viewAuthor'] = $authorid;
            }
        }
    }
}
die('Params shown');
This should give us some debug code with which to contiue.

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
secu
Regular
Posts: 14
Joined: Sun May 30, 2010 7:35 am

Re: wrong selection when generating RSS feeds for categories/aut

Post by secu »

Thanks a lot, Garvin.
You did much work here.

I'll dig into that this weekend and then post the results.
secu
Regular
Posts: 14
Joined: Sun May 30, 2010 7:35 am

Re: wrong selection when generating RSS feeds for categories/aut

Post by secu »

Hello Garvin,

I'm awfully sorry for the delay. To be honest, I just was rather overloaded with a complicated migration job the last two weeks. However, thanks a lot for your help. Just right now I went through the steps you propsed.

Here are the results:
garvinhicking wrote: Inside your .htaccess you should have a line like this:

Code: Select all

RewriteRule ^(feeds/categories/[0-9a-z\.\_!;,\+\-\%]+\.rss) index.php?/$1 [NC,L,QSA]
This is the rule that should match due to your permalink setup. To check if that rule works, you could modify it to:

Code: Select all

RewriteRule ^(feeds/categories/[0-9a-z\.\_!;,\+\-\%]+\.rss) test.php?/$1 [NC,L,QSA]
then create a test.php file with a simple "Hello world", and then try to call your RSS feed to see if it redirects there.

If that properly works,
That worked.
garvinhicking wrote: revert the change and we'll take on the index.php file next. Inside that file at around line 325 you should see:

Code: Select all

} elseif (preg_match(PAT_PERMALINK_FEEDCATEGORIES, $uri, $matches) || preg_match(PAT_PERMALINK_FEEDAUTHORS, $uri, $matches) || preg_match(PAT_FEEDS, $uri)) {
to test if the RSS feed properly leads there, you can modify it to:

Code: Select all

} elseif (preg_match(PAT_PERMALINK_FEEDCATEGORIES, $uri, $matches) || preg_match(PAT_PERMALINK_FEEDAUTHORS, $uri, $matches) || preg_match(PAT_FEEDS, $uri)) {
die('Hello world - RSS feed contents here');
and then save, test the RSS feed URL again and see.
Positiv too.
garvinhicking wrote: If that also shows the proper output, the next step is to see why the category is not shown. For that, this code exists:

Code: Select all

    if (is_array($matches)) {
Inserting the debug code you provided lead to the following output:

Code: Select all

Array ( [0] => feeds/categories/2-Mix-Proxy-Malfunctions.rss [1] => 2 ) PATTERN: feeds
URI: /feeds/categories/2-Mix-Proxy-Malfunctions.rss
PAT: mix-proxy-servers-categories
PAT2: feeds/categories/%id%-%name%.rss
Array ( [0] => /feeds/categories/2-Mix-Proxy-Malfunctions.rss [1] => /feeds/ [2] => categories/2-Mix-Proxy-Malfunctions ) Params shown
I still have the modified lines active in case you might want to test anything using the frontend.
garvinhicking wrote: This should give us some debug code with which to contiue.
As I'm no PHP type at all this does not really enlighten me, but almost probably you can get some useful information from this. Hope so however :-)

Is there anything I furtheron could do ?

Kind regards
Tom
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: wrong selection when generating RSS feeds for categories/aut

Post by garvinhicking »

Hi!

I believe the problem is actually with the categories.

Ypu have feeds/categories/ as permalink path for categories, but /mix-proxy-servers-categories/ as your category path. What I wasn't aware of is that those two have dependencies, so you should try to configure your RSS feed category path as:

feeds/mix-proxy-servers-categories/%id%-%name%.rss

HTH,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
secu
Regular
Posts: 14
Joined: Sun May 30, 2010 7:35 am

Re: wrong selection when generating RSS feeds for categories/aut

Post by secu »

Ha !

that did it :-)

And also that works likewise for the authors RSS feed now.

Thanks a lot once more.
Am on my way to http://wishes ... ;-)

Tom
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: wrong selection when generating RSS feeds for categories/aut

Post by garvinhicking »

Hi!

Great to hear it works! I received your donation - that's very kind of you, I'm gonna spend it in some entertaining stuff. :-)

Best regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Post Reply