http://api.drupal.org/api/function/hook_node_access_records
In this function description, it is mentioned that each item in the returned array should contain a field with a 'grant_edit' key. This is incorrect, it should be 'grant_update' instead. Nothing wrong with the code, but the API documentation is off. The error is present in all versions, Drupal 5, 6 and 7.

http://api.drupal.org/api/function/db_result
http://api.drupal.org/api/function/db_fetch_array
http://api.drupal.org/api/function/db_fetch_object
The only problem here is that the documentation is a bit misleading for these functions. I would prefer that each of them clearly states whether they advance the internal pointer in the sql result object they return values from. db_result does not, and it can be used to return one value only from a single row. The other two do, and they can be used to read all rows from the result object in a loop. I tried to use db_result in a similar fashion, and got an endless loop as a result.

Best thing really would be to change db_result so that it does advance the internal pointer. That way it would be more useful, and extending its functionality thus shouldn't break any existing module either - unless they do the dumb thing of fetching the same value from the same result object twice. In Drupal 7 perhaps?

CommentFileSizeAuthor
#2 grant_update.patch889 bytescasey

Comments

catch’s picture

Title: An API bug and omissions » node_access API documentation/omissions

changing title.

casey’s picture

Status: Active » Needs review
StatusFileSize
new889 bytes

patch replaces grant_edit with grant_update in node.api.php (only place grant_edit was being used)

db_result, db_fetch_array and db_fetch_object don't exist anymore in d7.

casey’s picture

Status: Needs review » Reviewed & tested by the community

so tiny and clear...

webchick’s picture

Version: 7.x-dev » 6.x-dev
Status: Reviewed & tested by the community » Patch (to be ported)

Committed to HEAD. Thanks! Moving to 6.x.

rdrh555’s picture

Assigned: Unassigned » rdrh555

If agreeable, I would need access (developer/hooks/) to take this one on; thanks!

jhodgdon’s picture

Status: Patch (to be ported) » Fixed

Actually it looks like someone already made the change.
http://api.drupal.org/api/function/hook_node_access_records

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.