Using the latest dev from this morning, I created a new group and add a post from the brief node form as the same user. The post is created, but the group is not associated.

Next, went to Engineering Group where I had become a member. Tried to create brief node form post. The post is created, but the group is not associated.

Next, went to my newly created group from above. Clicked go to full form. The request parameter was there and the group was prepopulated. Tried to submit but got the error:
The referenced entity (node: 7) is invalid.
(7 is the id of the new group)

Next, went to engineering group, clicked to go to full node form. Everything was populated correctly and the node submitted as expected.

Comments

ezra-g’s picture

Status: Active » Postponed (maintainer needs more info)

Can you clarify where you're getting the latest dev package of Commons from?

Please note that per the nightly dev snapshot tarball release notes:

ightly development snapshot of Commons 7.x-3.x. Please note that to get an up-to-date snapshot, you need to package Commons locally with the command:

drush make build-commons-dev.make

until #1983606: Move some of the Commons_* modules into the Commons distro repo is resolved.

RobKoberg’s picture

Yes, I am using the dev make file:

$ drush make --no-cache --working-copy build-commons-dev.make ../commons-7.x-3.x-dev

Are you not seeing this?

ezra-g’s picture

Status: Postponed (maintainer needs more info) » Active
Issue tags: +Commons 7.x-3.3 radar

I hadn't seen it before but wanted to confirm we're looking at the same versions before attempting to reproduce.

Thanks for the clarification - Tagging for review before 3.3.

RobKoberg’s picture

Status: Active » Postponed (maintainer needs more info)
Issue tags: -Commons 7.x-3.3 radar

Looking into this more, the $group_id is being passed to commons_bw_partial_node_form(). The $form_state['group_id'] = $group_id; is being set. It is set to 7

Debugging in the commons_bw_partial_node_form_submit():

  // Set the group audience.
  if (!empty($form_state['group_id'])) {
    $wrapper->{OG_AUDIENCE_FIELD}->set(array($form_state['group_id']));
  }
  watchdog('debug', '$wrapper->{OG_AUDIENCE_FIELD}->value(): <pre>'. print_r($wrapper->{OG_AUDIENCE_FIELD}->value()) . '</pre>');
  $wrapper->save();

The result of the debug is:

$wrapper->{OG_AUDIENCE_FIELD}->value() == 1

It should not be 1, it should be 7.

There are other notices and warnings, but don't look like they would affect this? They do come before my debug in the log so they were hit before the $wrapper->save():
Notice: Undefined variable: gids in commons_radioactivity_incident_groups() (line 148 of /Users/rkoberg/Sites/commons-dev/commons-7.x-3.x-dev/profiles/commons/modules/contrib/commons_radioactivity/commons_radioactivity.module).
Warning: Invalid argument supplied for foreach() in commons_trusted_contacts_node_presave() (line 850 of /Users/rkoberg/Sites/commons-dev/commons-7.x-3.x-dev/profiles/commons/modules/contrib/commons_trusted_contacts/commons_trusted_contacts.module).
2 of the following:
Notice: Undefined property: stdClass::$form_state in commons_trusted_contacts_node_presave() (line 850 of /Users/rkoberg/Sites/commons-dev/commons-7.x-3.x-dev/profiles/commons/modules/contrib/commons_trusted_contacts/commons_trusted_contacts.module).
Then comes my debug from above.

ezra-g’s picture

Status: Postponed (maintainer needs more info) » Active
Issue tags: +Commons 7.x-3.3 radar

Thanks for that debugging!

Restoring the issue status and tag.

Any chance you're able to file a patch?

RobKoberg’s picture

StatusFileSize
new1017 bytes

In #4, I should have wrote:

$wrapper->{OG_AUDIENCE_FIELD}->value() == array(1)

It should not be array(1), it should be array(7).

Not sure what you mean about a patch. Is it just for the debug messages? I have not fixed anything. (anyway one is attached)

I also added:

  watchdog('debug', '$form_state[\'group_id\']: '. $form_state['group_id']);
  // Set the group audience.
  if (!empty($form_state['group_id'])) {
    $wrapper->{OG_AUDIENCE_FIELD}->set(array($form_state['group_id']));
  }
  watchdog('debug', '$wrapper->{OG_AUDIENCE_FIELD}->value(): <pre>'. print_r($wrapper->{OG_AUDIENCE_FIELD}->value()) . '</pre>');
  $wrapper->save();

which produced:

$form_state['group_id']: 7

ezra-g’s picture

I was encouraging you to file a patch to fix the problem per your debugging, rather than print the debugging information :).

RobKoberg’s picture

Ah, OK. Where you able to reproduce? This seems like a showstopper. I am kind of at a loss. Any more help trying to debug would be appreciated. See more info below.

Actually, my previous debugging was not working correctly. I think watchdog was choking on the amount of info I was trying to print out. I changed it to store the result in a variable to display on form view. So in the form_submit, I have:

  if (!empty($form_state['group_id'])) {
    $wrapper->{OG_AUDIENCE_FIELD}->set(array($form_state['group_id']));
  }
  variable_set('debug_commons_bw_partial_node_form_submit_group_ref_before', $wrapper->{OG_AUDIENCE_FIELD}->value());
  $wrapper->save();
  variable_set('debug_commons_bw_partial_node_form_submit_group_ref_after', $wrapper->{OG_AUDIENCE_FIELD}->value());
  variable_set('debug_commons_bw_partial_node_form_submit_new_node_after', $wrapper->value());

And I found a hook_node_insert in commons_groups and added:

function commons_groups_node_insert($node) {
  variable_set('debug_commons_groups_node_insert_node', $node);
  $account = user_load($node->uid);
  commons_groups_first_contribution($account, $node);

Then I dpm() those variables in commons_bw_partial_node_form(). The result:
debug_commons_bw_partial_node_form_submit_group_ref_before = the correct group object
debug_commons_groups_node_insert_node = the new node, but the og_group_ref property is an empty array
debug_commons_bw_partial_node_form_submit_group_ref_after = the correct group object
debug_commons_bw_partial_node_form_submit_new_node_after = the new node, but the og_group_ref property is an empty array

RobKoberg’s picture

Attached are a couple of screen grabs showing the output of the last two variables.

japerry’s picture

Assigned: Unassigned » japerry
Priority: Normal » Critical

I can reproduce with or without additional content.

Steps:
1) install with or without sample content
2) enable og user access module
3) rebuild permissions
4) try to create a post within a group.

You get this:

Notice: Undefined property: stdClass::$form_state in commons_trusted_contacts_node_presave() (line 844 of /Users/japerry/Sites/commons/repos/modules/commons_trusted_contacts/commons_trusted_contacts.module).
Notice: Undefined property: stdClass::$form_state in commons_trusted_contacts_node_presave() (line 850 of /Users/japerry/Sites/commons/repos/modules/commons_trusted_contacts/commons_trusted_contacts.module).
Warning: Invalid argument supplied for foreach() in commons_trusted_contacts_node_presave() (line 850 of /Users/japerry/Sites/commons/repos/modules/commons_trusted_contacts/commons_trusted_contacts.module).
Notice: Undefined variable: gids in commons_radioactivity_incident_groups() (line 148 of /Users/japerry/Sites/commons/repos/modules/commons_radioactivity/commons_radioactivity.module).
- See more at: http://commons3/groups/engineering-team?qt-commons_bw=commons_all#sthash.k5XEt5KG.dpuf
ezra-g’s picture

The problem may be that https://drupal.org/node/1975198#comment-7418988 was never committed.

RobKoberg’s picture

OK, that is not in the code. I am working on something else now and can't test. If you put that in does it fix the issue? If so can you commit it :)

japerry’s picture

Status: Active » Needs review
StatusFileSize
new613 bytes

This should fix the errors surrounding public posting with og_access enabled.

ezra-g’s picture

Looks like japerry committed the patch referenced in #11 a few minutes ago: http://drupalcode.org/project/commons_bw.git/commit/89ec4a3.

ezra-g’s picture

StatusFileSize
new946 bytes

I re-rolled #13 to combine the additional conditions into the existing check for og_access module and added a descriptive code comment.

This patch allows me to target a post into groups from the short form with and without og_access module enabled.

japerry’s picture

Status: Needs review » Reviewed & tested by the community

re-roll looks good to me

ezra-g’s picture

Status: Reviewed & tested by the community » Fixed
RobKoberg’s picture

Confirming fixed.

ezra-g’s picture

Thanks for the confirmation!

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

Anonymous’s picture

Issue summary: View changes

changed type/incorrect wording