My site is giving off the following messages when creating a new posting. The site has external media field content types enabled, and the site was just a couple days ago upgraded from drupal 5 to 6. I did disable all contributed modules before doing the upgrade and reenable them afterward. However getting the external media fields to work right afterward .. well, they're not fully working. In any case this one issue seems to have a fairly clear cause.
Message:
user warning: Duplicate entry '7214-0' for key 1 query: content_write_record /* reikiman : content_write_record */ INSERT INTO content_field_external_audio (vid, nid, delta) VALUES (7214, 6062, 0) in /chroot/home/planethe/visforvoltage.org/html/sites/all/modules/cck/content.module on line 1207.
This gets printed several times.
This is towards the end of content_write_record where it's decided that this is an INSERT due to $update being empty. content_write_record is only called from two locations in the immediately prior function. At one call location it checks whether a record with the given key already exists, and sets $update which in turn causes an SQL UPDATE rather than an SQL INSERT.
In the other call location it does not make this check hence all calls to content_write_record from that location will end up being SQL INSERT's.
Hence it seems likely that a prior edit for a bug fix only fixed one location and missed the other? Maybe? Dunno. It's a guess. In any case if I rewrite the second call location to match the first then the message goes away.
diff -r 0586200b7597 sites/all/modules/cck/content.module
--- a/sites/all/modules/cck/content.module Thu Mar 26 17:23:12 2009 -0400
+++ b/sites/all/modules/cck/content.module Thu Mar 26 17:23:31 2009 -0400
@@ -1062,7 +1062,12 @@
$record['nid'] = $node->nid;
$record['vid'] = $node->vid;
$record['delta'] = $delta;
- content_write_record($db_info['table'], $record);
+ if (db_result(db_query("SELECT COUNT(*) FROM {". $db_info['table'] ."} WHERE vid = %d", $node->vid))) {
+ content_write_record($db_info['table'], $record, array('vid'));
+ }
+ else {
+ content_write_record($db_info['table'], $record);
+ }
}
}
}
This is with
// $Id: content.module,v 1.301.2.85 2008/11/10 15:56:35 yched Exp $
| Comment | File | Size | Author |
|---|---|---|---|
| patch.diff | 760 bytes | reikiman |
Comments
Comment #1
yched commentedNope, the current code is correct. For multiple fields, the code branch starts by clearing all the existing values, so all the values we add are inserts, not updates.
The issue is rather that there are several attempts to insert the same (vid, delta) values several times. If this only happens with the 'embedded media' field type, then maybe it's a bug in there ?
Comment #2
pyxio commentedDid you ever get this solved? I am having the exact same problem with the line 1207 php error. Please let me know how you resolved it. Thanks. Kevin
Comment #3
keinstein commentedThis might be a duplicate of #732382