All pastes #36230 Raw Edit

Unnamed

public text v1 · immutable
#36230 ·published 2006-01-09 05:37 UTC
rendered paste body
Problem: Can't add any kind of node.

Why? node_access always returns false.

so this... (from node_add)

    foreach (node_list() as $type) {
      if (node_access('create', $type)) {
        // ...never gets here!
        $out = '<li>';
        $out .= ' '. l(node_invoke($type, 'node_name'), "node/add/$type", array('title' => t('Add a new %s.', array('%s' => node_invoke($type, 'node_name')))));
        $out .= " <div style=\"margin-left: 20px;\">". implode("\n", module_invoke_all('help', 'node/add#'. $type)) .'</div>';
        $out .= '</li>';
        $item[node_invoke($type, 'node_name')] = $out;
      }
    }

and this (from node_access):

  if ($op == 'create' && ($grants = node_invoke_nodeapi($node, 'create'))) {
    // ...never gets here!
    foreach ($grants as $grant) {
      if (!$grant) {
        return FALSE;
      }
    }
  }
  
Because...

function node_invoke_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
  $return = array();
  foreach (module_list() as $name) {
    $function = $name .'_nodeapi';
    if (function_exists($function)) {
      $result = $function($node, $op, $a3, $a4);
      // $result is always empty!
      if (is_array($result)) {
        $return = array_merge($return, $result);
      }
      else if (isset($result)) {
        $return[] = $result;
      }
    }
  }
  // ...and this always returns 0!
  return $return;
}