Hi,

i have 2 content types ;
partner where i added an imagefield, partner_logo, with unlimited number of images,
and pictureset, where i added an imagefield, photo, with unlimited number of images.

Every time i create a node of one of these content-type, i get the following error, on save :

user warning: Duplicate entry '692-0' for key 1 query: INSERT INTO content_field_photo (vid, nid, delta, field_photo_fid, field_photo_list, field_photo_data) VALUES (692, 618, 0, 413, 1, 'a:3:{s:11:\"description\";s:6:\"dddddd\";s:3:\"alt\";s:14:\"aaaaaaaaaaaaaa\";s:5:\"title\";s:0:\"\";}') in xxx/sites/all/modules/cck/content.module on line 1213.

i do not get the error when i edit and save, only on first creation (insert).

both content types work well for other fields.

The node is created and editable, but i can't get rid of the error message.

i use d6.16, cck 2.6, filefield 3.2, and image_field 3.2.

i reinstalled my module from rock bottom, and tried a lot of tests in différent configurations, but i got the error every time.

Any idea on how to get rid of this annoying msg ?

Thank you

Comments

chipway’s picture

of course, the msg refers a different field name depending onthe CT, partner_logo or photo.

chipway’s picture

if i limit the number of photo to 10, i get 10 error msg.

chipway’s picture

if i limit the number of photo to 2, i get 2 error msg, even if i put 2 or 1 photo.

only when i set number limit to 1, it works without the error msg.

chipway’s picture

Project: ImageField » Content Construction Kit (CCK)
Version: 6.x-3.2 » 6.x-2.x-dev
Component: Code » content.module

Moved the issue because of the following tests :

i deleted the image_field photo2, and created an brand new photo2 image_filed, with unlimited number. I got also the Duplicate entrey ... 1213 issue.

I deleted the new photo2 field, and created a simple TEXT field with unlimited number. and ... got the error (only on adding a node) :

user warning: Duplicate entry '695-0' for key 1 query: INSERT INTO content_field_test_multi (vid, nid, delta, field_test_multi_value, field_test_multi_format) VALUES (695, 621, 0, '

test this multi text field 1

', 2) in xxx/www/sites/all/modules/cck/content.module on line 1213.

So the issue is really a cck issue.

I have already used multiple field on cck some times ago, but now there a bug.

i tried both cck 6-2.6 and 6-2.dev = same issue.

Thank you for any idea on how to solve this.

Leon

GuyPaddock’s picture

Perhaps this is related to #626314?

chipway’s picture

Hi GuyPaddock,

Thank you for your reply, but it is not related to FileField paths, as we do not use FileField paths.

As i didn't get any solution, we have gone to setting up a new content type to manages these multiples values in a specific CT.

So now we only use single value for the field in our main CT.

But the issue is still there.

Thanks

GuyPaddock’s picture

I wasn't necessarily saying that it was because you were/weren't using FileField paths. It's just that, the issue sounds so similar that I think both are related to the same underlying CCK issue.

keinstein’s picture

I get a similar error message not using filefield. But as far as I can see #626314 might be the same problem.

I'm trying to debug this problem. I created a backtrace of _all_ insert operations an the corresponding table. It turns out, that it there are at least three calls to content_storage, where the first two are called with “update“ as first argument and the third with “insert“ generating the error message.

Also the nesting depth is different.

The SQL query is the same.

Update: It looks as if there were a race condition with the trigger module involved.

keinstein’s picture

Changing the weight for trigger to 1 and for content to -1 solves the issue for me.

Anonymous’s picture

I'm having the same issue (see #626314: FileField paths causes "duplicate entry" error when saving a node with empty fields). How can I change the weight of modules? I'm not using the trigger module.

keinstein’s picture

You can do it by manually changing the system table in your database.

But be careful.

Anonymous’s picture

Thanks a lot! Changing the weight of the content module to -1 or the one of the FileField paths module to 1 solves the issue for me.

fuscata’s picture

I was getting this error when trying to save a node in code:

content_presave($node);
node_save($node);
content_insert($node);

This fixed the problem (you'll have to set $isNew prior to this code):

content_presave($node);
node_save($node);
if ($isNew) {
    content_insert($node);
} else {
    content_update($node);
}
TrevorBradley’s picture

Aha! I was getting this error on creation of new content. It was actually very simple to recreate:

1) Create a new node
2) Create a CCK text field, and set it to an unlimited checkbox (changing the content from the content_type_* content_field_* tables)
3) Create content programatically in CCK, but don't set the value of the checkbox.

$node->title = "Test Node";
$node->type = "test1";
$node ->field_test_one[]['value'] = "Test Value"; //Not the checkbox

node_save($node);
content_insert($node);
unset($node);

The solution for me was very simple, and fuscata (#13) gave me the clue. I was using "content_insert". Switching over to "content_update" makes the problem go away, and still works fine for non-multiple type fields. (content_insert still works great for non-multiple fields)

WinstonC’s picture

This patch did fix the problem for me. Hope the CCK developer can review this.

http://drupal.org/node/709306#comment-3247540

KarenS’s picture

Status: Active » Fixed

This is not a patch for CCK, it is an explanation of how to create custom code to update nodes. There is nothing to review or commit.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

phayes’s picture

Status: Closed (fixed) » Active

This issue was never actually resolved. It was marked as fixed even though no commit or change was applied.

phayes’s picture

phayes’s picture

Status: Active » Needs review
Maedi’s picture

#12 Works for me too!

hefox’s picture

The patch is a bandaid and doesn't actually address whatever the real bug is -- should not need to /delete/ records during an insert. The question is, what's inserting and why?

hefox’s picture

Status: Needs review » Active

Setting it to active as the patch isn't actually posted for this issue; however, I think this is a case of bugs in other contrib modules modules so this should be be ether won't fix or duplicate.