Improper pubDate for feed in rss2.0

Found a bug? Tell us!!
Post Reply
xzilla
Regular
Posts: 10
Joined: Wed Aug 16, 2006 5:05 pm
Contact:

Improper pubDate for feed in rss2.0

Post by xzilla »

My scenario is that I wrote a blog post about 2 weeks ago but left it as draft. I published a few articles since then. When I went to publish it yesterday, I updated the time to be the current date so that it would be the latest entry. On my website, it is the first entry, and when I look in my rss feed it is also the first entry, however my rss feed has picked up the original date of the post as the pubDate for the feed (coming from syndicate plugin), meaning all of the blogg aggregators think my feed is two weeks old and wont update :-(

I noticed in _entries that the timestamp field contains yesterdays date, but last_modified contains the date from two weeks ago. I'm not sure if the fix for this is that last_modified should be updated when the timestamp is updated, or that the rss syndicate plugin needs to pull timestamp as the pubDate... any thoughts?
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Improper pubDate for feed in rss2.0

Post by garvinhicking »

Hi!

Which serendipity version are you using? Usually when you save a published entry, the last_modified date should get updated.

In your case, if you only saved the draft and go to publish, then serendipity does intentionally not push the last_modified date, to preserve the original timestamp. So, actually all you should need to do is to save your current entry once again, and then last_modified should be updated to the latest timestamp.

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/
xzilla
Regular
Posts: 10
Joined: Wed Aug 16, 2006 5:05 pm
Contact:

Post by xzilla »

This is using s9y 1.0.

I actually did try to modify the entry to update the last_modified date, but for some reason it didnt change the last_modified date at all. Unless there is some logic in the code the checks the amount of change before updating last modified, this probably means there is some other bug going on in there, but thinking about it further, I don;t think that is the right solution anyway...

To me the problem is that the blog pubDate is being populated by a different field than the individual entry pubDates. Since the individual entries in the rss feed and the website display itself all base thier publish dates based on the timestamp field, istm that the overall feed pubdate should also use this field so that all three items are in synch... am I missing something there?

simple change makes the above happen:


*** include/plugin_internal.inc.php 2006-08-17 07:04:46.000000000 -0700
--- include/plugin_internal.inc.php.rht 2006-08-17 07:05:47.000000000 -0700
***************
*** 1010,1016 ****
switch($match[1]) {
case 'pubDate':
if (serendipity_db_bool($bag_content)) {
! $bag_content = gmdate('D, d M Y H:i:s \G\M\T', serendipity_serverOffsetHour($entries[0]['last_modified']));
} else {
$bag_content = '';
}
--- 1010,1016 ----
switch($match[1]) {
case 'pubDate':
if (serendipity_db_bool($bag_content)) {
! $bag_content = gmdate('D, d M Y H:i:s \G\M\T', serendipity_serverOffsetHour($entries[0]['timestamp']));
} else {
$bag_content = '';
}
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

Yes, the channel's pubdate is identical to the timestamp of any last update to a s9y entry, which will push the Conditonal Get caching of an RSS feed to refresh, when an existing entry is changed.
I actually did try to modify the entry to update the last_modified date
How did you do that?

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/
xzilla
Regular
Posts: 10
Joined: Wed Aug 16, 2006 5:05 pm
Contact:

Post by xzilla »

garvinhicking wrote:Hi!
Yes, the channel's pubdate is identical to the timestamp of any last update to a s9y entry, which will push the Conditonal Get caching of an RSS feed to refresh, when an existing entry is changed.
RIght, but the thing is that if you change the timestamp of a given entry, you will change the order of entries in both your website and your rss feed, which to me means you should probably also send a note for people to come and grab your feed again no?

I guess the central question is does change a time on a blog entry mean you have updated your content, and therfore you should tell blog readers to refresh the feed. I think it does.
I actually did try to modify the entry to update the last_modified date
How did you do that?
In the entry I changed some text from HTH to hope this helps. I thought saving that text change would have been enough to cause the last_updated column to be modified., but it didn't change it.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!
RIght, but the thing is that if you change the timestamp of a given entry, you will change the order of entries in both your website and your rss feed, which to me means you should probably also send a note for people to come and grab your feed again no?
Yes, which is why serendipity also pushes the last_modified timestamp when you save a published entry and change things like the timestamp.
In the entry I changed some text from HTH to hope this helps. I thought saving that text change would have been enough to cause the last_updated column to be modified., but it didn't change it.
Was that entry a draft or a published one? Could you try it with an entry that is more recent (not older than 5 days) and see if that updates the last_modified timestamp? Actually it should. :-)

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/
xzilla
Regular
Posts: 10
Joined: Wed Aug 16, 2006 5:05 pm
Contact:

Post by xzilla »

garvinhicking wrote:Hi!
RIght, but the thing is that if you change the timestamp of a given entry, you will change the order of entries in both your website and your rss feed, which to me means you should probably also send a note for people to come and grab your feed again no?
Yes, which is why serendipity also pushes the last_modified timestamp when you save a published entry and change things like the timestamp.
Well then I guess I have a bug going on here, because mine is not updating last_modified when I update the timestamp.
In the entry I changed some text from HTH to hope this helps. I thought saving that text change would have been enough to cause the last_updated column to be modified., but it didn't change it.
Was that entry a draft or a published one? Could you try it with an entry that is more recent (not older than 5 days) and see if that updates the last_modified timestamp? Actually it should. :-)
No. I tried it with one that was 3 days old and i get the same behavior.

(time elapses)

And now I have tried it with a brand new draft entry and it still doesn't update the last modified time. :-(
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!
And now I have tried it with a brand new draft entry and it still doesn't update the last modified time. :-(
You mean you do that:

1. You create a draft entry. Date it to like 2006-08-19.
2. You wait a day.
3. You publish your draft entry. Time will stick at 2006-08-19, timestamp as well.
4. You wait a day.
5. You modify your now public entry. Save it. Then the timestamp will stay at 2006-08-19, but last_modified should then be set to 2006-08-21?

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/
xzilla
Regular
Posts: 10
Joined: Wed Aug 16, 2006 5:05 pm
Contact:

Post by xzilla »

I finally had some time to investigate, and I think the problem comes from this change in includes/functions_entries.inc.php

http://svn.berlios.de/wsvn/serendipity/ ... v=756&sc=1

specifically, the check for isdraft -->

if ($entry['isdraft'] === 'false' && $_entry['isdraft'] === 'false') {
$entry['last_modified'] = time();
}

$_entry['isdraft'] actually returns f, which afaict will not validate above, and so the last modified time never updates. I think this might be a postgresql issue, since returning f is a libpqism afaik. Changing this to === 'f' seems to make things work properly again. Any thoughts? Any other pg users notice this problem?
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

Please mention everytime that you are using postgresql. :-D

Postgresql behaves so wickedly different in many cases like the one here, where I don't know further. It would've helped us some time *g*

It might work with this code:

Code: Select all

if (!serendipity_db_bool($entry['isdraft']) && !serendipity_db_bool($_entry['isdraft'])) {
    $entry['last_modified'] = time();
}
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/
xzilla
Regular
Posts: 10
Joined: Wed Aug 16, 2006 5:05 pm
Contact:

Post by xzilla »

tee hee... we like to keep you on your toes. I had worked up a similar fix using serendipity_db_bool but yours works as well. I can submit a patch if you want but I suspect you've got it from here. Thanks much for the feedback.
judebert
Regular
Posts: 2478
Joined: Sat Oct 15, 2005 6:57 am
Location: Orlando, FL
Contact:

Post by judebert »

Shall I commit this one, too?
Judebert
---
Website | Wishlist | PayPal
Post Reply