When mail2web or mailcomment (same module) add a comment, comment_cck updates all cck fields to null. This is similar to an issue these modules have/had with casetracker, but I was not able to covert that fix for this (it was pretty specific to casetracker). I'm not a dev, but have lots of vm / hosting resources for testing / etc.

CommentFileSizeAuthor
#4 comment_cck.patch1.64 KBnachinius

Comments

Azol’s picture

Do you have "CCK Fieldgroup" module enabled?

obrienmd’s picture

I've tried both with it enabled and disabled.

Azol’s picture

Could you also check system log of your Drupal website for possible errors?
And you'd better keep CCK Fieldgroup enabled while testing, because of #669954: "Argument #2 is not an array" error

nachinius’s picture

Component: Miscellaneous » Code
Status: Active » Needs review
StatusFileSize
new1.64 KB

Since no info in mailcomment is made about the cck fields, they get deleted in the
node because comment_cck interprets that a deletion had occurred.

Mailcomment don't make any assertion about cck fields, and they pass a comment
with uninitialized cck fields. Comment_cck merges this uninitialized cck-fields against the real node with array_merge.

From http://ar2.php.net/manual/en/function.array-merge.php

array array_merge ( array $array1 [, array $array2 [, array $... ]] )
Merges the elements of one or more arrays together so that the values of one are appended to the end of the previous one. It returns the resulting array.

If the input arrays have the same string keys, then the later value for that key will overwrite the previous one. If, however, the arrays contain numeric keys, the later value will not overwrite the original value, but will be appended.

If only one array is given and the array is numerically indexed, the keys get reindexed in a continuous way.

The keys here are set, however the values are uninitialized. In consequence, the cck-fields in the node are overwritten with bad values. Therefore,
they get erased from the node.

I changed that line to use a different kind of merging, one that don't delete the original node cck field value if
the new value isn't set (even though the key exists).

Find the patch attached.

This fix was sponsored by obrienmd.