Sitemap contains items set to a future publish time

Found a bug? Tell us!!
Post Reply
Cenic
Regular
Posts: 20
Joined: Wed Jul 16, 2008 11:09 am

Sitemap contains items set to a future publish time

Post by Cenic »

Hi,

I have created an item that has been set to be published at a point in time in the future. Currently the item does not show up on my blog. So far, so good.

Then I noticed that the link to the article was already present in the sitemap generated by the sitemap plugin (version: 0.46). Accessing the published link gave a 404 error as expected.

It seems that the sitemap plugin does not honor items published in the future when the sitemap is generated. In my opinion those articles should not show up in the sitemap until they are really available. Obviously it is unfeasible to regenerate the sitemap when the article is due but I would rather have items missing in the sitemap than have items that do not yet exist.

The fix would be to include an additional clause in the queries used by the plugin to filter entries that have a timestamp in the future. In PostgreSQL one could use something like the following:

Code: Select all

...
AND entries.timestamp < (SELECT EXTRACT(EPOCH FROM current_timestamp))
...
It looks like MySQL does not support the exact same syntax. Maybe it would be the best way to generate the current timestamp in PHP and then use that as literal in the queries.

Regards,
Stefan
If Java had true garbage collection, most programs would delete themselves upon execution. (Robert Sewell)
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Sitemap contains items set to a future publish time

Post by garvinhicking »

Hi!

you are right, many thanks for noticing. I've just committed a fix for this to be contained in the next plugin version 0.47, available through spartacus within the next 24-48 hours.

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/
Don Chambers
Regular
Posts: 3657
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Re: Sitemap contains items set to a future publish time

Post by Don Chambers »

Nice observation Stefan!! Excellent suggestion! :wink:
=Don=
Post Reply