Sometimes it appears that $group->children is an empty string, which foreach() doesn't like.

* Warning: Invalid argument supplied for foreach() in field_group_attach_groups() (line 1654 of path/to/field_group/field_group.module).

This error repeats for each group in the form, on the final page of the node entry process.

7.x-1.1+65-dev

Comments

xurizaemon’s picture

Status: Active » Needs review
StatusFileSize
new884 bytes
xurizaemon’s picture

Think this issue might come up when displaying node field settings for nodes which don't use field_group?

Seen also @ admin/commerce/products/types/CONTENTTYPE/fields - where that content type doesn't use field groups at all.

xurizaemon’s picture

xurizaemon’s picture

Looks like I need to sort this for field_group/field_group.features.inc in_array() in line 23 also.

xurizaemon’s picture

Title: Invalid argument for foreach() in field_group_attach_groups() » Fix various E_NOTICE errors when referring to variables or array values which may not be set
StatusFileSize
new2.52 KB
xurizaemon’s picture

xurizaemon’s picture

xurizaemon’s picture

At some point I may get bored of incrementing this patch in tiny steps and take time instead to read the Field Group codebase, but for now I'm just gonna keep bumping this along :P

Latest patch should include all previous, just to be clear.

xurizaemon’s picture

meichr’s picture

Hi,
I tried to reproduce the error you reported, but was unable to reproduce it by the information you have given. Could you please describe in more detail how to reproduce these errors?

I have tested with
Drupal 7.22
PHP 5.3.14
PHP 5.2.17
Enabled error display by adding

error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);

at the beginning of index.php in the root directory.

I also debugged using Netbeans 7.2.1 trying none, one and more empty groups during content type editing under the tab "manage fields" and "manage display" and by node creation and node editing.
When no field is within a field group the variable $group->children within the foreach statement on line 1654 contains "array(0)" and stepping over it produces no E_NOTICE error.

If you could describe the steps and used versions of Drupal and PHP and other conditions to reproduce the errors, I'll try again to check errors and review patches.

Thanks,
Christian.

xurizaemon’s picture

I think it went like this -

1. Enable field group.
2. Configure field groups on content type TYPE_A.
3. Visit admin/structure/types/manage/TYPE_B/display.

meichr’s picture

Hi,
sorry, still no success in reproducing. This is how I prepare:

Installation

1. Drush makefile in Document root directory: d7fieldgroup.make

core = 7.x
api = 2
projects[drupal][version] = "7.22"
projects[ctools] = 1.3
projects[field_group] = 1.x-dev

2. Drush and Linux commands

# drush make d7fieldgroup.make --yes
# drush  si --yes --db-url=mysql://<dbuser>:<dbpassword>@localhost<:port>/<dbname> --site-mail=<email@adddress> --site-name="D7 Field Group Test" --account-mail=<email@address> --account-name=admin --account-pass=<password>
# chown -R <apacheusr>:<apachegrp> sites/default/files
# chmod -R 777 sites/default/files
# drush en ctools field_group

Steps To Reproduce

3. Enter URL path admin/structure/types/manage/article/fields
4. Add new group "Article Group", "group_article_group", "Fieldset"
5. Drag field "Body" into group.
6. Save
7. Enter URL path admin/structure/types/manage/page/display
8. No error (E_NOTICE) displayed.

What about the ctools version?
Can you change any of my steps for reproducing?
I also tried adding groups at admin/structure/types/manage/article/display and other combinations.

Thanks,
Christian.

meichr’s picture

Hi,
maybe my drush make script and description were not helpful to you. Are you using drush? Do you have a test site on your local computer to reproduce the error?

At the moment it looks to me that either the error cannot be reproduced or you are using contributed or custom modules which cause your problem and are not mentioned in the Issue Summary. Do you still have this error on your website, if you don't have your patch applied?

Can you describe a minimum setup of Drupal core and contributed modules incl. versions to reproduce the problem?

xurizaemon’s picture

Status: Needs review » Postponed (maintainer needs more info)
Issue tags: +E_NOTICE errors

@meichr - I probably won't have an opportunity to reproduce this, and I agree it's likely due to some other modules installed.

Here's a list of the enabled modules on that site: https://gist.github.com/5719318e7a2e652202e4

I'll mark this postponed, and maybe if someone else runs into the same issue in future, the patch above will help them.

AFAIK it should be harmless, from memory all it does is check that the values referred to in the module code are actually set.

rclemings’s picture

Issue summary: View changes

DISREGARD: There was a problem (two extra, empty field groups) with a profile2 export/import; fixed that and the error vanished. Sorry for the noise.

I think it may be addressfield that's responsible here. At least those are the fields that are giving me this error and I see it's also one of the modules listed in #14.

nils.destoop’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)