I had an XML sitemap user report a bug where the result of node_access() was being stored in an int field as '3' instead of 0 or 1. The documentation for node_access() says that the function should return TRUE if the operation is allowed, but if there are node grants, we return the value of a COUNT(*) query.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 555128-node-access-boolean-D6.patch | 2.59 KB | dave reid |
| #1 | 555128-node-access-boolean-D7.patch | 1.57 KB | dave reid |
Comments
Comment #1
dave reidAttached patch changes the query to a SELECT 1 .... LIMIT 0, 1 to help speed it up (see http://drupal.org/node/224333#select_count) and casts the result to a boolean. Also revises the documentation to say that it will return FALSE otherwise.
Comment #2
dave reidBackport patch for Drupal 6
Comment #4
dave reidSetting back to CNR due to http://testing.drupal.org/node/50.
Comment #5
moshe weitzman commentedNice fix. The ability to return values higher than 1 is a relic from some dark old days. This is better.
Comment #6
webchickCommitted to HEAD. Thanks!
Marking down to 6.x for consideration. It's an API change, but the current behaviour seems wrong.
Comment #7
gábor hojtsyOk, this fixes the return value to be as documented, so committed to Drupal 6 too.