Empty fields should not be displayed on nodes. But if you migrate nodes that have empty fields from D6 to D7 the label, with an empty value, appears on the node form. If you save the node without making any changes the value is hidden as it should be.

Digging into the database to figure out the difference between these values before and after the change and the difference between new fields in D7 that are left empty and those migrated it, I figured out that migrated fields are creating table records with a null value, but when you edit a node or create a new field from scratch that has an empty value, no record is inserted into the field table.

So the answer is to test for empty values during the migration and *not* create table entries for empty values. This sounds messy and complicated (each field has its own idea of what is 'empty').

I have no good idea how to incorporate this into the migration. Hopefully someone else will.

CommentFileSizeAuthor
#3 cck-1150790-2.patch1.06 KBjelenex
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

KarenS’s picture

Status: Active » Fixed

Actually turned out to be not so hard to fix. By the time we save the data we have a new field configured and we can use the 'is_empty' function for that field.

jelenex’s picture

Status: Fixed » Needs work

By debugging the whole migration process using XDebug, I found that this new _is_empty check introduced a new bug which prevents saving records. The problem is that various _is_empty check functions expect the value in $item['value'] but the items coming from CCK have values in $items['field_name_value'], therefore the record is marked as empty and not saved at all.

jelenex’s picture

Status: Needs work » Needs review
FileSize
1.06 KB

Here's a patch which tries to resolve the problem. The extra code is taken from the field_sql_storage_field_storage_load function in field_sql_storage module. Unfortunately, this operation slows down the migration a bit..

jelenex’s picture

Status: Needs review » Closed (fixed)