While working on the D6 port, I discovered a critical bug in CCK's field data storage.
When editing a field's settings, there are some boundary cases which can result in the loss of the data stored in the field for all nodes.

Specifically, this happens when a field update involves both changing the 'multiple' status *and* a field setting that changes the collection of db columns used to store the data.
Typical case is changing a (non-shared) text field from 'single' to 'multiple' *and* from 'filtered text' to 'plain'.
Fortunately, you don't get to do that everday. Besides this bug is probably here since the very early CCK 4.7 releases, and has never been reported AFAICT.

Only the field types whose set of columns depends on the fields settings are affected. To my knowledge, that's only :
- 'core CCK' text fields
- contrib Date.module date fields
but I'm not familiar with *all* contrib CCK fields available out there.

Attached patch should fix that, but since it affects the most critical part of CCK (data storage), we need to fully and extensively test this before committing (even to a -dev release).

I already tested the patch with text fields. Additional help welcome (esp. contrib field developpers) :
- Please report any contrib field modules that could be affected.
This means : a field module for which the set of columns returned by hook_field_settings($op = 'database columns') depends on something the site admin can change on the field edit form.
- For those field types only (no need to test nodereference or imagefields), mess up with the field's settings in all possible ways you can think of :-) :
use a field that is not shared across multiple content types
change the field from single to multiple values (or back) *and* some of the relevant field settings
check that you don't get any SQL errors, and that your nodes still contain the right data for the field
use a test site, obviously :-)

CommentFileSizeAuthor
content_admin.inc_.patch1.88 KByched

Comments

wim leers’s picture

Only the field types whose set of columns depends on the fields settings are affected.

That means the Money CCK field isn't affected. Phew :)

yched’s picture

yes, the very large majority of field modules won't be affected. But it's hard for me to check them all by myself, so :-)

markfoodyburton’s picture

If I understand right, the problem is exhibited on things like, or using the text field - so widgets using text field would suffer. I have a couple of those... but I assume this is covered by the text field case itself - presumably it's not worth checking other widgets...?

yched’s picture

@markfoodyburton : The bug is not dependent on anything related to widgets.
It is know to happen with text fields - in the CCK sense : fields provided by CCK's text.module.
This is not to be confused with textfields "the Form Element" (as in the $form['foo'] = array('#type' => 'textfield') FAPI declaration) :-)

Number fields, for instance, have their default widget based on a FAPI's '#type' = 'textfield' form input, they are not affected by that bug.

rconstantine’s picture

Since you don't know all contrib modules intimately, would you like a list of those that shouldn't be affected as well as those for which the patch works? That way if people come here wondering if one they've installed is at-risk, they'd know? If so, here are mine. Thanks for the alert.

Not affected:
- cck_address - as it uses the same number of fields every time
- cck_fullname - as it also uses the same number of fields every time
- cck_taxonomy_ssu - for the same reason

eammae’s picture

i have this problem encountered in the module. When i try to post an ad having a price of 9.95 then submitted it, the post and the system changed the price to 9.94 USD. The very obscure thing here is that when I edited the post to change the price to 9.96, the system keeps it at 9.96...
If I change it to 9.951, the system changes it to 9.95. Only the 9.95 and 8.95 changes to 8.94 and 9.94 but the rest is ok. Is there anyone who experience things like this?

yched’s picture

@eammae : this looks completely unrelated - are you sure you commented in the right issue ?

wim leers’s picture

Status: Needs review » Closed (fixed)

I think it's safe to close this issue now :)