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?
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | grant_update.patch | 889 bytes | casey |
Comments
Comment #1
catchchanging title.
Comment #2
casey commentedpatch 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.
Comment #3
casey commentedso tiny and clear...
Comment #4
webchickCommitted to HEAD. Thanks! Moving to 6.x.
Comment #5
rdrh555 commentedIf agreeable, I would need access (developer/hooks/) to take this one on; thanks!
Comment #6
jhodgdonActually it looks like someone already made the change.
http://api.drupal.org/api/function/hook_node_access_records