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

zorroposada’s picture

I 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:

Notice: Trying to get property of non-object in workbench_moderation_node_access() (line 378 of /var/www/mysite/docroot/sites/all/modules/contrib/workbench_moderation/workbench_moderation.module).

And

Notice: Trying to get property of non-object in node_access() (line 2914 of /var/www/mysite/docroot/modules/node/node.module).

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/"

timhare’s picture

Hook_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.

Version: 7.12 » 7.x-dev

Core issues are now filed against the dev versions where changes will be made. Document the specific release you are using in your issue comment. More information about choosing a version.