Closed (fixed)
Project:
Organic groups moderation
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
28 Mar 2012 at 07:24 UTC
Updated:
23 May 2012 at 15:59 UTC
A PHP warning is emitted when attempting to create a new node.
The problem lies in line 28 in og_moderation.module, in function og_moderation_form_alter:
<?php
function og_moderation_form_alter(&$form, &$form_state, $form_id) {
if (isset($form['#node_edit_form'])) {
if ($form['#node_edit_form'] && og_is_group_content_type('node', $form['#bundle'])) {
if ($gids = og_get_entity_groups('node', $form['#node'])) { // <---- This line causes the problem.
foreach($gids as $gid) {
if (og_user_access($gid, "access publishing options of " . $form['#bundle'] . " content")) {
$form['options']['#access'] = TRUE;
}
if (og_user_access($gid, "access revisions options of " . $form['#bundle'] . " content")) {
$form['revision_information']['#access'] = TRUE;
}
}
}
}
}
}
?>The function og_get_entity_groups is called with the node object stored in $form['#node']. Since this is a new node, this node object does not have the node ID set.
Add a check to see if the node object in $form['#node'] has nid set before calling og_get_entity_groups:
<?php
function og_moderation_form_alter(&$form, &$form_state, $form_id) {
if (isset($form['#node_edit_form'])) {
if ($form['#node_edit_form'] && og_is_group_content_type('node', $form['#bundle'])) {
// Old line:
// if ($gids = og_get_entity_groups('node', $form['#node'])) {
if (isset($form['#node']->nid) && $gids = og_get_entity_groups('node', $form['#node'])) { // New line
foreach($gids as $gid) {
if (og_user_access($gid, "access publishing options of " . $form['#bundle'] . " content")) {
$form['options']['#access'] = TRUE;
}
if (og_user_access($gid, "access revisions options of " . $form['#bundle'] . " content")) {
$form['revision_information']['#access'] = TRUE;
}
}
}
}
}
}
?>
Comments
Comment #1
shenzhuxi commentedfixed.
But you need to pay attention that this is due to Drupal core http://drupal.org/node/1102570
It can also happen in other place. http://drupal.org/node/1368930
Comment #2
mwallenberg commentedGreat! Thanks for a nice module, by the way - it allows for some really solid publishing workflows using og that just aren't possible without it.
Comment #4
lord4gb commentedThank you so much! Great fix.
Comment #5
jordisan commentedI hope this modification will be included in the next release
Comment #5.0
jordisan commentedfix typos