Sitemap contains items set to a future publish time
Posted: Sat Apr 18, 2009 5:11 pm
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:
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
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))
...Regards,
Stefan