When field instance has multi-level settings array and it's overridden - field_instance_features_rebuild()
function will not revert this field instance because if ($field_instance + $existing_instance !== $existing_instance) {
will return FALSE.
My proposal is to use drupal_array_diff_assoc_recursive($field_instance + $existing_instance, $existing_instance)
instead - it will return real diff for multi-level settings.
Unfortunately we can't use features_array_diff_assoc_recursive()
because it's not working properly with multi-level arrays.
Only one issue should be fixed - drupal_array_diff_assoc_recursive
will not handle 0
and '0'
values correctly so it should be excluded from comparison if both values are the same (==).
Example of multi-level field instance settings array:
$field_instances['node-article-field_image'] = array(
'bundle' => 'course',
'deleted' => 0,
...
'widget' => array(
'active' => 1,
'module' => 'media',
'settings' => array(
'allowed_schemes' => array(
'oembed' => 0,
'private' => 0,
'public' => 'public',
),
'allowed_types' => array(
'audio' => 0,
'document' => 0,
'image' => 'image',
'video' => 0,
),
'browser_plugins' => array(
'media_default--media_browser_1' => 'media_default--media_browser_1',
'media_default--media_browser_my_files' => 0,
'media_internet' => 'media_internet',
'upload' => 'upload',
),
),
'type' => 'media_generic',
),
);
In this case if $field_instances['node-course-field_image'] ['widget']['settings']['browser_plugins']['upload']
was changed from 'upload' to 0 or vice versa - it will not be reverted due to wrong comparison algorithm.