I have used both the dev and stable version of Entity Reference and this notice appears:
Notice: Trying to get property of non-object in entity_metadata_no_hook_node_access() (line 609 of C:\wamp\www\osdb\sites\all\modules\contrib\entity\modules\callbacks.inc).
Notice: Trying to get property of non-object in entity_metadata_no_hook_node_access() (line 610 of C:\wamp\www\osdb\sites\all\modules\contrib\entity\modules\callbacks.inc).
Notice: Trying to get property of non-object in entity_metadata_no_hook_node_access() (line 610 of C:\wamp\www\osdb\sites\all\modules\contrib\entity\modules\callbacks.inc).
Notice: Trying to get property of non-object in entity_metadata_no_hook_node_access() (line 609 of C:\wamp\www\osdb\sites\all\modules\contrib\entity\modules\callbacks.inc).
Notice: Trying to get property of non-object in entity_metadata_no_hook_node_access() (line 610 of C:\wamp\www\osdb\sites\all\modules\contrib\entity\modules\callbacks.inc).
Notice: Trying to get property of non-object in entity_metadata_no_hook_node_access() (line 610 of C:\wamp\www\osdb\sites\all\modules\contrib\entity\modules\callbacks.inc).
The entity_access() function takes as its third parameter an $entity object while the reference module is passing the bundle name instead of an object.
entity_access($op, $entity_type, $entity = NULL, $account = NULL)
The references_dialog_entityreference_link_helper() function calls entity_access without passing the full $entity.
if (entity_access('create', $entity_type, $entity_type == 'node' ? $bundle : NULL) &&
I'm not sure which module is responsible for this problem.
Comments
Comment #1
Adam S commentedThis is probably an Entity API as node_access() requires the $node parameter to be either a node or in the case of node create a string of the bundle or node type name.
Comment #2
Adam S commentedI patched the Entity API at http://drupal.org/node/1780646
Comment #3
mile23More work has been done on #1780646: entity_access() fails to check node type specific create access and the determination from Fago is: You have to pass in an entity, even if it's one you create as a prototype for the operation.
Bumped to major because this is a bit of a blocker for that other issue: https://drupal.org/node/1780646#comment-7750019
Comment #4
wodenx commentedThe original issue belongs in the references_dialog project.
Comment #5
b-prod commentedFixed in the DEV version:
Comment #6
b-prod commentedFor those who want a patch against 7.x awaiting the next release.
Comment #7
JvE commentedThis should do it:
Comment #8
Yaazkal commentedHi, I was getting this error message when trying to create a node that uses References Dialog (this message is not showed, but is in the drupal log):
EntityMalformedException: Permission to create a node was requested but no node type was given. in entity_metadata_no_hook_node_access() (line 672 of /sites/all/modules/entity/modules/callbacks.inc).Code on comment #6 fixed it, thanks.
Could be a good option to release other alpha or even beta version including this, because it can prevent many users to have this error.
Regards
Comment #9
hansfn commentedFYI: The fixed is included in the new 7.x-1.0-beta1 release, but it's forgotten in the release notes.
Comment #10
nicxvan commentedI am still receiving this error. I am on beta-1: The following error is posted in my logs.
EntityMalformedException: Permission to create a node was requested but no node type was given. in entity_metadata_no_hook_node_access() (line 678 of /sites/all/modules/entity/modules/callbacks.inc).
Comment #11
nicxvan commentedSome notes so I can make a patch later if my reasoning is sound I went through a couple iterations. I need to compare against a clean version and create a patch, but this currently allows for updating and creating nodes with entity reference.
I will post a patch shortly.
94: // Should likely be node_access since it's node_load and can only be nodes
if (node_access('update', $node)) {
119: //
if (node_access('create', $node_type->type)) {
208:
if (entity_access('update', $entity->type, $entity)) {
280: // entity access can check based on the kind of entity, no need to have separate node logic I think
$access = entity_access('create', $bundle);
Comment #12
nicxvan commentedThis is ready to be reviewed and tested. I can now visit new pages with reference dialogs and existing pages.
Comment #14
JvE commentedLooks like you're confusing node types and entity types.
Examples of entity types: https://www.drupal.org/node/1261744
- node
- user
- comment
- taxonomy_term
Examples of node types: https://www.drupal.org/node/21947
- article
- basic page
- book page
- forum topic
- poll
About your patch:
This is wrong. entity_access expects an entity type here (node, user, taxonomy_term, etc.) not a node-type.
Space should not be removed.
Again, entity_access expects the entity type (node, user, taxonomy_term, etc.) and not the bundle (node type for nodes).
The only reason I can think of why this patch appears to help you is that you're running a pre-1.3 release of the Entity API module.
If you do get that error with the latest version of Entity, Entityreference and References dialog, I suggest you apply the patch from https://www.drupal.org/node/1780646?page=1#comment-8350335 to get more debug logging.
Comment #15
nicxvan commentedThanks for the insight, I am running entity 1.5 so that isn't the issue. I will try applying that patch and see if it exposes more information.
1. I do know the difference between node types and entity types, but I thought the entity object had a type field.
2. That was a mistake.
3. I may have misread how it works. I'll take your word for it though and try applying the patch you posted to gather more info. As you can see I'm fairly new at some of this.
Comment #16
gints.erglis commentedHere's a different approach - passed entity is empty so it fails entity type check. I'm checking the entity before calling entity access function instead.