I've created a content type which contains several fields of various types.

I have found two issues when exporting the content type, and then subsequently importing the same content type.

1) Date - The date field does not render out (the pull downs do not show) after the import, and going to create content. If you edit the field and press save (even w/o making changes), then the field renders fine.

2) Nodereference - It doesn't seem to carry through the acceptable content types when imported. You must go edit the content type and re-check the acceptable types in order for the field to work.

-T

Comments

karens’s picture

Title: Import of date and node reference doesn't work » Serialized arrays are converted from numeric to boolean
Version: 6.x-2.0-rc4 » 6.x-2.x-dev
Priority: Normal » Critical

For nodereference, at least, the problem is that the exported array of referenceable types looks like:

array(
  'page' => TRUE,
  'story' => FALSE,
);

instead of

array(
  'page' => 1,
  'story' => 0,
);

I dug back through the code to see where those values are getting skewed, and got all the way back to content_field_instance_read(). When serialized arrays are pulled out of the database they are coming out with the boolean rather than numeric structure. That then fails to import correctly.

This affects $field arrays wherever they are used, and undoubtedly could be having some detrimental effect on allowed values lists and optionwidgets checkboxes, too.

We have to force those serialized arrays to be numeric, but I have no idea how to do that.

I'm bumping this to critical because I think this problem is more far-reaching than breaking some fields in Content Copy

karens’s picture

OK, here's what I found so far. This is *not* a general problem of data in the $field array getting garbled, it is specific to Content Copy (whew!)

However, the current way that Content Copy works has a critical problem because when drupal_execute() is run on a nodereference field, it garbles the values as noted above, and then saves that result, so not only is the export wrong, the original field settings have been destroyed. You have to go back and edit the settings manually to reset them.

As an example, create a content type with a nodereference field that references a couple other content types. Save it. Then export that field. Go back and check the settings on the field after your export and all the referenceable types selections will be missing.

I tried following this through to figure out exactly where it was getting garbled, but couldn't find it and gave up. However I found I can make it work right by force-feeding the current field values to drupal_execute() instead of allowing it to create its own.

I want to do a bit more testing to be sure it's working right, but I'll commit this shortly.

karens’s picture

And this is another reason why we need to get rid of drupal_execute on the export (we already got rid of it on the import). I think we'll still need it to create the content type, but we could use our API from that point on.

I don't have the time or energy to fix this now, though, so I'll focus on the quick fix above.

karens’s picture

Title: Serialized arrays are converted from numeric to boolean » Content copy destroys field settings

Renaming.

karens’s picture

Status: Active » Fixed

I committed this fix.

Anonymous’s picture

Status: Fixed » Closed (fixed)

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