Stack trace.
EntityMalformedException: Missing bundle property on entity of type comment. in entity_extract_ids() (line 7672 of /Users/jucallme/Sites/systemseed/sac_platform/7.x-3.x/build/includes/common.inc). Backtrace:
entity_extract_ids('comment', Object) og_features.module:750
og_features_get_group_context(1) og_features.module:344
og_features_menu_access_callback('node_access', 'comment_reply', Array, 'comment', 'comment/reply/%node', 'view', Object)
call_user_func_array('og_features_menu_access_callback', Array) menu.inc:636
_menu_check_access(Array, Array) menu.inc:789
_menu_translate(Array, Array) menu.inc:472
menu_get_item() menu.inc:1754
menu_get_custom_theme(1) menu.inc:1769
menu_set_custom_theme() common.inc:5117
_drupal_bootstrap_full() bootstrap.inc:2198
drupal_bootstrap(7) index.php:20
I have created a implemented the following.
We basically create a basic og_feature and then look at the state of the feature to see if it is enable or disabled. Then we remove or show the comments form biased on the state of the go_feature.
/**
* Implements hook_og_features_registry().
*
* Register your feature(s) with og_features so it can be toggled within
* a given group
*
* @return
* An array of information used to register your feature with
* og_features
*/
function sac_directory_og_features_registry() {
$registry = array();
// Feature: my_feature
$feature = new stdClass;
// The feature id
$feature->id = 'sac_directory';
// The name that will show up on the feature toggle form
$feature->name = t('Directory');
// The description that will show up on the feature toggle form
$feature->description = t('Enable / dissable commenting for the SAC Directory Item content types.');
// The components of the feature that will be enabled/disabled
$feature->components = array(
'variable' => array(
'comment_anonymous_sac_directory_item',
'comment_default_mode_sac_directory_item',
'comment_default_per_page_sac_directory_item',
'comment_form_location_sac_directory_item',
'comment_preview_sac_directory_item',
'comment_subject_field_sac_directory_item'
),
);
// It's recommended that you key the feature with the name of the
// module/feature that is supplying this, so that any custom page
// callbacks provided by this module/feature become disabled within
// the group
$registry[$feature->id] = $feature;
return $registry;
}
/**
* Implements hook_node_view_alter().
*/
function sac_directory_node_view_alter(&$build) {
$node = $build['#node'];
if (isset($node->og_group_ref[LANGUAGE_NONE][0]['target_id'])) {
$entity_id = $node->og_group_ref[LANGUAGE_NONE][0]['target_id'];
$entity_type = 'node';
$group = entity_load_single($entity_type, $entity_id);
if (is_array($group->features_disabled) && in_array('sac_directory', $group->features_disabled)) {
unset($build['links']['comment']['#links']['comment-add']);
$build['links']['comment']['#links']['comment_forbidden'] = array(
'title' => theme('comment_post_forbidden', array('node' => $node)),
'html' => TRUE,
);
$build['comments']['comment_form'] = array();
}
}
elseif (og_is_group_content_type('node',$node->type)) {
// This node has not been assigned to a group
// assume no commenting.
unset($build['links']['comment']['#links']['comment-add']);
$build['links']['comment']['#links']['comment_forbidden'] = array(
'title' => theme('comment_post_forbidden', array('node' => $node)),
'html' => TRUE,
);
$build['comments']['comment_form'] = array();
}
}
NOTE i can completely comment out sac_directory_node_view_alter and the exception is still thrown.
Commenting out the line
list($entity_id) = entity_extract_ids($entity_type, $entity);
in og_features_get_group_context get me passed the error but kills a lot of what that function is trying to do.
Comments
Comment #1
mstef commentedWell first, OG Features doesn't support variables per-group (although, that would be a great idea). If you know how we could do that, let me know.. The supported items are on the project page and inside the documentation.
Do me a favor. Put this right above that call to entity_extract_ids() (line 750 in .module): drupal_set_message(print_r(get_defined_vars(), 1)); - and past the output here.
Also, what page is this happening on?
Comment #2
roam2345 commented@mstef
- Im running out of memory even after bumping it up 512MB, after adding drupal_set_message(print_r(get_defined_vars(), 1));
- This is happening when creating a new comment on any node.
Comment #3
roam2345 commentedI have managed to get the output before running out of memory there.
attached is a screen shot with the out put.
and here is the raw output.
Comment #4
mstef commentedYou're using OG 2.x, right?
Comment #5
roam2345 commentedCorrect,
projects[og][subdir] = contrib
projects[og][download][type] = git
projects[og][download][url] = http://git.drupal.org/project/og.git
; projects[og][download][branch] = 7.x-2.x
projects[og][download][revision] = 4a1a139ff2b67ccebb3e151d6aa7a826f6358377
Comment #6
mstef commentedOkay, I can replicate. I'm looking in to this now.
Comment #7
mstef commentedWell, this is part of the big "hack" that og_features needs in order to properly determine group context; due to a few outstanding issues/bugs with OG2.
The problem here is that $entity_type is 'comment' but the entity object is actually a node.
I'll place that line inside a try{} and properly handle the entity exception quietly.
Comment #8
mstef commentedhttp://drupalcode.org/project/og_features.git/blobdiff/b05f9c2d549a78feb...
Comment #9
roam2345 commentedshould probably even wrap it in if ($entity_type != 'comment') {} as they will always fail.
thanks for the fix.
Comment #9.0
roam2345 commentedmore description