I've run into a very bizarre bit of improper functionality that I've not been able to track down. I am trying to get a list of all nodes in a given vocabulary, grouped by their taxonomy terms. Seems reasonable, and I've done it before. Here's the code:
function _resource_list() {
$resources = array();
$terms = taxonomy_get_tree(5, 0, -1, 1);
if ($terms) {
foreach ($terms as $term) {
$nodes = taxonomy_select_nodes(array($term->tid), 'or', 0);
$node_list = array();
while ($resource_node = db_fetch_object($nodes)) {
print "Found a node!";
$node_list[] = $resource_node;
}
print_r($node_list);
}
}
(Plus various return stuff, but I'm trimming out everything not related to the problem.)
If the current user has 'administer nodes' permission, then the print_r() call spits out an array with the correct nodes in it. If the current user does not have 'administer nodes' permission, then $node_list is empty. taxonomy_select_nodes() and db_fetch_object() don't check user_access() anywhere, though.
All nodes in that category are of type "resource" (a custom node type). The hook_access() for that node type is trivially simple:
function resource_access($op, $node) {
global $user;
print "<pre>Op: $op</pre>\n";
return true;
}
According to the print statement, though, it's never being called anyway (as it shouldn't be).