I've created a module that extends XML Sitemap by adding a custom context. The additional context allows the creation of different sitemaps which include nodes updated during a certain time period.

When using this module, you can create a new sitemap context for nodes from "all time" (in other words, a sitemap with the default XML Sitemap behaviour). In this case, I don't give the sitemap a context value. Or, more precisely, I remove the context value with unset($form_state['values']['context']['time']);. This is helpful for a site that installs my module but already has a sitemap configured - the owner isn't forced to replace their sitemap with a one that has a time context.

If the user attempts to create a sitemap with a custom context of, say, '30 days', and they have already got a '30 days' sitemap, XML Sitemap will throw an error and tell them that they can't create a duplicate. However, if they attempt to create a duplicate 'all time' sitemap, XML Sitemap tries to create the sitemap regardless and causes a duplicate key error in the database.

I realise that XML Sitemap traps duplicate inserts by preventing form submission if a dupe is detected, but what I'd like to request is some error handling around the database insert command itself (or a check before insertion that it's a valid insert). I realise that this problem is only being highlighted because I'm intentionally distorting the standard sitemap addition code with my module, but additional validity tests couldn't hurt and may help others in my position.

TL;DR: Please add validity testing or error checking to the sitemap database insert code for inserting contextless sitemaps.

Comments

PsycleInteractive created an issue. See original summary.

Psycle Interactive’s picture

Closing this issue, as a bug was found in our custom module, that extends the functionality of xmlsitemap, that was triggering the database error for duplicate key on entry into the database.

Psycle Interactive’s picture

Status: Active » Closed (fixed)