How to stop infinite loop on hook_node_grants I am using hook_node_grants to provide access to a realm based on whether someone is an 'owner' of a node. The issue is that menu_get_object() may call hook_node_grants recursively.

function hottopics_node_grants($account, $op) {
  $grants = array();
  ...
   try {
      $node = menu_get_object();
    } catch (Exception $e) {
      // URL mustn't be the correct format.
      return $grants;
    }
   ...
    // Is the person a member of the administrator group, or the owner of the parent node? 
    if (module_invoke('hottopicsresearch', 'display_moderated_research_access_callback', 'update', $node)) {
      $grants['view_hottopics_manager'] = array(1);
    }

    return $grants


The code recurses at $node = menu_get_object(). Drupal-7.
Load the node directly:

  // Do not use $node = menu_get_object();
  // This calls hook_access which results in a recursive loop
  $node_url = $_GET['q'];
  $nid = array_pop(explode('/', $node_url));
  if (!is_integer($nid)) {
    return $grants;
  }
  $node = node_load($nid);