I am trying to use a custom module to use the _fieldmap_objects hook so that I can set the import and export functions for a particular cck type to implement some custom behaviour that I need. When I implement the hook it gets called as expected and I set the import and export functions. The import function of the field ($drupal_object['fields']['field_mycustomfield'][import']) is now an array of size 2 rather than a string.

The problem happens in the array_merge_recursive in module_invoke_all, because the array result of my _fieldmap_objects hook is combined with the array result of the sf_node_fieldmap_objects. Rather one of the hooks overriding the other the two different import functions are combined into an array.

I thinking there are two ways to solve this and I am interested in your feedback before I start working on it.

1. We might be able to pass the $objects array in as a parameter and have the hooks modify that rather than returning an array result

2. Alter the import to always pick the last import method added.

I think #2 is hacky and #1 is probably ideal, but I don't know if there are other implications. Are there any other ways to tackle this problem?

Comments

aaronbauman’s picture

IMO, there should be a hook_fieldmap_objects_alter.

Any one else have ideas?

vfilby’s picture

Arron,

Looks like there is already a hook for fieldmap_objects_alter, I hadn't thought of looking for that. I'll give a try using that in the morning.

Vince

vfilby’s picture

Status: Active » Closed (fixed)

Aaron, works as advertised. Thank you!