in function content_storage()
switch ($op) {
...
case 'insert':
case 'update':
...
// Delete and insert, rather than update, in case a value was added.
if ($op == 'update') {
db_query('DELETE FROM {'. $db_info['table'] .'} WHERE vid = %d', $node->vid);
}
Why record is deleted only during the update, but not during insert?
Code after fix:
if ($op == 'update' || $op == 'insert') {
db_query('DELETE FROM {'. $db_info['table'] .'} WHERE vid = %d', $node->vid);
}
Patch in attachment.
Problem is related to:
http://drupal.org/node/259837#comment-1108886
http://drupal.org/node/259837#comment-1123160
Comments
Comment #1
kenorb commentedPatch.
Comment #2
andypostDelete on insert what for?
Comment #3
dagdag commentedI had a similar problem when a tried to save a content type that use a computed field to search in a database, it show me a duplicate warning for this field
so I have applied the patch and it seem works, no more warning message
-drupal 6.8
-cck 6.x-2.1
Comment #4
kenorb commentedProblem is as well with NodeReferrer module after converted to 6.x
http://drupal.org/node/259837
Delete on insert, because after few lines there is INSERT.
So cck write the same record twice as follow (see line with function content_write_record()):
Comment #5
dagdag commentedYes, I have this problem now, it insert duplicate values in a vocabulary I was looking but i not used with the drupal development, maybe can be an error in the multiple fields, another aspect is that the code is inserted in a switch structure if you simply let
db_query('DELETE FROM {'. $db_info['table'] .'} WHERE vid = %d', $node->vid);
whithout
if ($op == 'update' || $op == 'insert'){
it eliminates the duplicate warning but the duplicate error is maintained
the switch option for 'insert' is empty, maybe there is the best place to correct the mistake
Comment #6
Flying Drupalist commentedsubscribe
Comment #7
kenorb commentedUser reviews:
http://drupal.org/node/259837#comment-1159452
http://drupal.org/node/259837#comment-1165132
http://drupal.org/node/259837#comment-1237130
Comment #8
kenorb commentedComment #9
paulludington commentedSubscribe.
Comment #10
kenorb commentedComment #11
yched commentedI'm sorry but I'll need a little more explanation as to why this is needed.
How can there be, in a per-field table, rows than should be deleted for the vid of the node that is that is just *being created* ?
If this is specific to nodereferrer fields, then please describe briefly the code workflow that leads to this. I'm not familiar with nodereferrer and have little time to dive in there.
On a minor note, and *if* this is actually needed, then the remark in #5 is true : no need to test
if ($op == 'update' || $op == 'insert'), the if() test can simply go.Comment #12
andypostIs there some documentation about using new "multiple values" I don't know what the way is right http://drupal.org/node/259837#comment-1318962
Comment #13
yched commentedA widget needs to declare "multiple values" => CONTENT_HANDLE_MODULE when one single widget lets the user pick several values (for instance a select with #multiple set to TRUE). This tells CCK that it's not necessary to output several copies of the widget for fields that are 'multiple'.
Comment #14
kenorb commentedRelated topic: #397654: Multiple values
Comment #15
andypostSuppose fixed just removing multiple option
nodereferrer cant be multiple... so no need in multiple & required flag at all
Comment #17
dagdag commentedSo I had this problem some months ago even with the 6.13 release but with 6.14 it seems to be fixed
drupal 6.14
cck 6.x 2.5