Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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 CreditAttribution: 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.