I got this error message when trying to create a feature.
Warning: Invalid argument supplied for foreach() in conditional_fields_features_export_options() (Zeile 14 von /sites/all/modules/conditional_fields/includes/conditional_fields.features.inc).
This is the function:
function conditional_fields_features_export_options() {
$dependencies = conditional_fields_load_dependencies();
$entity_info = entity_get_info();
$options = array();
foreach ($dependencies as $type => $data) {
foreach ($data as $dependency => $info) {
$option = $type . ':' . $dependency;
if (!isset($options[$dependency])) {
$options[$option] = $entity_info[$type]['bundles'][$dependency]['label'] . ' (' . $type . ')';
}
}
}
return $options;
}
The function conditional_fields_load_dependencies(); can return "false" if there are no dependencies (?). I think this is what happens here. So I added this to check my findings:
if (!is_array($dependencies)) {
$dependencies = array();
}
Message gone.
Changed the code to this:
if (!is_array($dependencies)) {
return (array());
}
This code does not look good, so the patch is not good. But its late right now.
How could I do this in good coding style?
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | conditional-fields-features-dependencies-1569842-1.patch | 344 bytes | darrenmothersele |
| conditional_fields-features-integration.patch | 676 bytes | JThan |
Comments
Comment #1
darrenmothersele commentedI got the same error message. I think instead of patching
conditional_fields.features.incwe should patchconditional_fields_load_dependencies()so that it returns an empty array when there are no dependencies.Comment #2
JThan commentedSounds good to me, I just did not know what implications this could have at other places in the module. But it is definitely better to solve this at the place you solved it. So, let someone test this?
Comment #3
yvmarques commentedThanks, for the patch #1 works for me !
Cheers,
-- Yvan
Comment #4
IshanComBr commentedpatch #1 works for me also
TKS!
Comment #5
peterpoe commentedCommitted, thanks!
Comment #6.0
(not verified) commentedTypo