Just did a fresh install of the latest Commons 7 dev (dated Jan 10) and got this when I went to create a new Post:
Warning: Invalid argument supplied for foreach() in og_field_widget_form() (line 69 of /home/clients/websites/w_comm7/public_html/comm7/profiles/commons/modules/contrib/og/includes/og.field.inc).
Warning: Invalid argument supplied for foreach() in entityreference_field_widget_form() (line 815 of /home/clients/websites/w_comm7/public_html/comm7/profiles/commons/modules/contrib/entityreference/entityreference.module).
Warning: Invalid argument supplied for foreach() in entityreference_field_widget_form() (line 815 of /home/clients/websites/w_comm7/public_html/comm7/profiles/commons/modules/contrib/entityreference/entityreference.module).

CommentFileSizeAuthor
#8 no_group_node_add_fix.patch527 bytesmmilano

Comments

jlea9378’s picture

On creation of the Post I got two more warning/notices:

Warning: Invalid argument supplied for foreach() in commons_radioactivity_incident_groups() (line 140 of /home/clients/websites/w_comm7/public_html/comm7/profiles/commons/modules/contrib/commons_radioactivity/commons_radioactivity.module).
Notice: Undefined variable: gids in commons_radioactivity_incident_groups() (line 144 of /home/clients/websites/w_comm7/public_html/comm7/profiles/commons/modules/contrib/commons_radioactivity/commons_radioactivity.module).

jlea9378’s picture

It looks like some of the errors were already reported: #1837308: Error (unable) in creating New posts

But I'm confused about if there is a fix or not. It is marked as a duplicate of another issue which I am not clear as to whether or not there is a fix for it. The referenced issue is confusing with all of the duplicate references and stuff on it.

As previously mentioned I'm using the latest dev release on a clean install: Commons (commons-7.x-3.0-beta1+14-dev)

Topcheese’s picture

@jlea9378, yes it is kind of confusing. I followed the links and it looks like there is a new patch for OG groups. The patch might still need to be reviewed, but I didn't see the new patch after the last patch failed automated testing, so we might have to wait for a release.

jlea9378’s picture

ohh it is the patch on here you are referring to I think: #1845050: reference field set to "Autocomplete (Tags style)" not returning any matches
Thanks.

jlea9378’s picture

I tried to apply the patch but it said "Reversed (or previously applied) patch detected!". So does the Jan10th dev release already include this patch?

Topcheese’s picture

Yeah, sorry about that. I had checked the link again and it said "fixed," and not "needs review." It looks like the patch was applied to Organic Groups 7.x-2.x on Jan 03, so Commons Jan 10 should have it.

jlea9378’s picture

Anyone know how to get rid of these errors?

mmilano’s picture

Status: Active » Needs review
StatusFileSize
new527 bytes

There are 2 elements to this:

1) The og widget isn't testing for if there are actually targets, and running a foreach on a variable that is not an array. I posted a patch over there for that: #1895270: Error when creating content outside of a group.

2) After submitting content without a group associated, commons_radioactivity does something similar. (Even after the patch above is applied)

Warning: Invalid argument supplied for foreach() in commons_radioactivity_incident_groups() (line 140 of ...profiles/commons/modules/contrib/commons_radioactivity/commons_radioactivity.module).
Notice: Undefined variable: gids in commons_radioactivity_incident_groups() (line 144 of ...profiles/commons/modules/contrib/commons_radioactivity/commons_radioactivity.module).

Attached is a patch for commons_radioactivity that add a test for the array before it runs the foreach.

mmilano’s picture

Title: Warning: Invalid argument supplied for foreach() in ... » Adding content with no group generates array errors

Updating title to reflect the issue.

ezra-g’s picture

Status: Needs review » Needs work

We actually do:

  // If this node is a member of groups, generate an incident for each group.
  if (!empty($node->og_group_ref)) {
    commons_radioactivity_incident_groups($node, $value);
  }

But this should be a check of

 if (!is_array($node->og_group_ref[LANGUAGE_NONE])) {

as in the patch in #8.

Marking "needs work" so we can have a single check for this code. This would likely be resolved in the larger, longer term cleanup effort by #1804888: Commons_radioactivity.module contains group-specific functionality.

matt v.’s picture

For what it's worth, I'm unable to recreate the issue on a newly built Commons site, based on the latest dev release. I was able to add new test posts to the site without any errors, both with and without Groups assigned to the posts.

jlea9378’s picture

I get an error when I try to download the latest commons. Looks like there is already an open issue for that though.

Topcheese’s picture

@jlea9378, is that using Drush? I just downloaded TTW today.

jlea9378’s picture

No, the link on the project page for dev tar.gz file. It didn't work yesterday but now it is working.

ezra-g’s picture

Status: Needs work » Fixed

For what it's worth, I'm unable to recreate the issue on a newly built Commons site, based on the latest dev release. I was able to add new test posts to the site without any errors, both with and without Groups assigned to the posts.

Please re-open if you're able to reproduce with the latest nightly dev snapshot.

Status: Fixed » Closed (fixed)

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

Honestly Illustrated’s picture

Version: » 7.x-3.2
Status: Closed (fixed) » Active

See #16 of #1953242: Getting error while posting new questions...

I've swapped issue version because 7.x-3.2 is where I'm seeing this issue, and date on that is 2013-Apr-04 compared to February 3, 2013 for #15 comment here.

ezra-g’s picture

Status: Active » Closed (fixed)

Issues are marked fixed when they are fixed in the codebase, not when the fix is released. This fix will be included in the 7.x-3.3 release of Commons, due out this June.

I suggest taking a few moments to read about conventions forusing the issue queue to help you get the most value from it.

Honestly Illustrated’s picture

Thanks, ezra.

I wouldn't know whether it takes one month or four to take a bug fix from codebase to release, when there has been a release one month after fix in codebase. I do know what "fixed" means here, though: a fix exists.