Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hello,
When logged in with other than administrator, there's a notice in a red box :
Notice : Trying to get property of non-object in node_node_access() (line 2932 of C:\wamp\www\drupal-7.12\modules\node\node.module).
On the line 2932 :
/**
* Implements hook_node_access().
*/
function node_node_access($node, $op, $account) {
$type = is_string($node) ? $node : $node->type;
if (in_array($type, node_permissions_get_configured_types())) {
if ($op == 'create' && user_access('create ' . $type . ' content', $account)) {
return NODE_ACCESS_ALLOW;
}
if ($op == 'update') {
if (user_access('edit any ' . $type . ' content', $account) || (user_access('edit own ' . $type . ' content', $account) && ($account->uid == $node->uid))) {
return NODE_ACCESS_ALLOW;
}
}
if ($op == 'delete') {
if (user_access('delete any ' . $type . ' content', $account) || (user_access('delete own ' . $type . ' content', $account) && ($account->uid == $node->uid))) {
return NODE_ACCESS_ALLOW;
}
}
}
return NODE_ACCESS_IGNORE;
}
Does anyone know how to solve this problem ?
Thanks
Comments
Comment #1
zorroposada CreditAttribution: zorroposada commentedI am also having an issue with node access. I receive this error message for authenticated users that do not have the
"bypass node access"
permission:And
And
Notice: Trying to get property of non-object in node_access() (line 2921 of /var/www/mysite/docroot/modules/node/node.module).
This happens when I go to any page under path
"/admin/workbench/"
Comment #2
timhare CreditAttribution: timhare commentedHook_node_access expects either a node object or the node type as a string. If you call it with, for example, a node id, it produces the error because is_string returns false for an integer value. Calling it this way is an error in the calling code, but node_node_access could be coded more defensively. Minimally it could be
$type = is_object($node) ? $node->type : $node;
It isn't clear whether it would be desirable to detect the integer and attempt to load the node, or to let the code fail silently.