I'm getting the following error in recipe module when trying to update the recipe node with "create new revision" checked:
user warning: Duplicate entry '3' for key 1 query: INSERT INTO recipe (nid, source, yield, notes, instructions, preptime) VALUES (...
Taking a quick look, I noticed this code in recipe update:
// if this is a new node or we're adding a new revision,
if ($node->revision) {
recipe_insert($node);
}
else {
db_query("UPDATE {recipe} SET source = '%s', yield = '%s', notes = '%s', instructions = '%s', preptime = '%d' WHERE nid = %d", $node->source, $node->yield, $node->notes, $node->instructions, $node->preptime, $node->nid);
recipe_save_ingredients($node);
}
Seems like this is the offending code. I don't think we want to insert a new recipe at this point, as node_update will take care of the revision process. As it stands, recipe and ingredient information is not revision-enabled anyway, so I'm not sure you even need a check until you start keying based on rid instead of nid.
I'll submit a patch in a few, but I wanted to post the issue first to make sure I had not missed anything.
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | recipe_update.patch | 1.05 KB | seanbfuller |
Comments
Comment #1
seanbfuller commentedThis small patch removes the check to call hook_insert in hook_update that was causing an SQL error when trying to update a recipe node where revisions where turned on. Without this check, the node updates successfully and revisions are created properly.
Comment #2
marble commentedThanks, applied. It seems drupal has quite a lot of functionality I've not even tried to use yet!
Comment #3
(not verified) commented