These warning messages appear in _features_override_set_additions() and _features_override_set_deletions().

The foreach in both these functions is being passed (possibly due to improper creation of feature overrides?) single strings, single ints, classes (which is ok), arrays, and arrays that qualify as isset() but would fail on !empty().

The single strings (of value '0', string length 1), single ints, and arrays that are empty() are all throwing warnings when foreach tries to process them.

Are all data types acceptable parameters for argument 1 of _features_override_set_additions()? Knowing what the expected data types are for this parameter will help me save some time while troubleshooting this on my end.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mrfelton’s picture

Title: Invalid argument supplied for foreach() in _features_override_set_additions() » Invalid argument supplied for foreach() in _features_override_set_additions() and _features_override_set_deletions()

Same issue for me here.

kclarkson’s picture

I got this as well Undefined index: additions in features_overrides_features_export_options() (line 38 of

Letharion’s picture

@kclarkson, that's a different issue.

Letharion’s picture

Seemingly stemming from the same problem, not validating the inputs, can also yield Warning: array_keys() expects parameter 1 to be array, null given in features_override_module_component_overrides() from the code if (!array_key_exists($key, $normal)) {, at line 318 at the time of writing.

mpotter’s picture

Status: Active » Fixed

I believe this is fixed in the latest -dev release. I think only arrays are supposed to be passed, but I'll need to double-check. Please feel free to reopen this if the original issue isn't fixed.

If you are having a different error or in a different code location, please create a new issue.

Status: Fixed » Closed (fixed)

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

vinmassaro’s picture

Status: Closed (fixed) » Active

Using 7.x-2.x-dev, I am running into the same issue when exporting an image style override for the 'thumbnail' image style that comes with the standard Drupal 7 install. It does not activate the overridden style (Scale and Crop instead of Scale) but does have my updated dimensions. It also continues to display the 'Override defaults' submit button. On features module pages, I get these errors:

Warning: Invalid argument supplied for foreach() in _features_override_set_additions() (line 253 of /sandbox/d7/sites/all/modules/contrib/features_override/features_override.export.inc).
Warning: Invalid argument supplied for foreach() in _features_override_set_deletions() (line 305 of /sandbox/d7/sites/all/modules/contrib/features_override/features_override.export.inc).
smk-ka’s picture

Priority: Minor » Normal
Status: Active » Needs review
FileSize
1.83 KB

Some components do not export arrays or objects, but simple strings, which the _features_override_set_*() functions try to iterate over. This patch simplifies those functions by bailing quickly if encountering a scalar variable, while afterwards only needing to differentiate between objects and arrays.

aschiwi’s picture

Thank you smk-ka. I just applied your patch from #8 and the errors went away. Couldn't see any other/new problems.

marcelovani’s picture

I fixed this problem with a different approach then #8
I am checking the type of the variables instead.

Andrew Edwards’s picture

@vinmassaro I've created a similar issue here with a hacky work around #1834342: Cannot override default image styles. I think it's similar to yours ... although I got a different error message.

vinmassaro’s picture

@Andrew Edwards thanks for the heads up. I ended up just exporting an additional image style in my feature instead of using Features Override to change the default thumbnail.

Angry Dan’s picture

is_scalar is no good at finding NULLs. I think a better approach is something like this: http://stackoverflow.com/questions/3584700/iterable-objects-and-array-ty... to explicitly check if you can loop over the elements.

Will post a patch if I get more time

jeremylichtman’s picture

I'm finding many places in features_overrides where it is assuming that every feature encountered will have overrides (obviously not the case).

I put in is_array checks in a few places in my local install:

features_override_features.inc - three places in features_overrides_features_export_options()
features_override_export.inc - in features_override_export_keys()

Those two seem to get rid of the error messages I was experiencing. They're obviously just stop-gap measures, as I haven't dug in enough to get a feel for the architecture or coding style of this module.

SocialNicheGuru’s picture

#14 can you create a patch that can be tested?

marcelovani’s picture

@SocialNicheGuru, @jeremylichtman I have posted the patch that does exactly this on #10, which I am using. Can anyone else test to eventually get this committed?

marcelovani’s picture

Status: Needs review » Active
marcelovani’s picture

Status: Active » Needs review
afoster’s picture

I've applied the patch in #10 to the latest dev. It's fixed the errors. Thank you.

marcelovani’s picture

Status: Needs review » Reviewed & tested by the community
BarisW’s picture

Status: Reviewed & tested by the community » Patch (to be ported)

Can this be ported to D6 too? I'm having the same issues here (using Drupal Commons).

BarisW’s picture

Status: Patch (to be ported) » Reviewed & tested by the community

Ah apologies, I was too quick. This doesn't seem to be committed to de 7.x branch yet. Let's await that first.

BarisW’s picture

Here's the D6 port of the same patch in #10. Fixes the issues for me.

mpotter’s picture

Status: Reviewed & tested by the community » Fixed

Committed to ed1df0e.

BarisW’s picture

Version: 7.x-2.x-dev » 6.x-2.x-dev
Status: Fixed » Patch (to be ported)

Thanks, now also D6?

ZeiP’s picture

Issue summary: View changes
Status: Patch (to be ported) » Closed (outdated)

Drupal 6 is no longer supported.