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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Dave Reid’s picture

Status: Active » Needs review
FileSize
1.57 KB

Attached 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.

Dave Reid’s picture

Backport patch for Drupal 6

Status: Needs review » Needs work

The last submitted patch failed testing.

Dave Reid’s picture

Status: Needs work » Needs review

Setting back to CNR due to http://testing.drupal.org/node/50.

moshe weitzman’s picture

Status: Needs review » Reviewed & tested by the community

Nice fix. The ability to return values higher than 1 is a relic from some dark old days. This is better.

webchick’s picture

Version: 7.x-dev » 6.x-dev

Committed to HEAD. Thanks!

Marking down to 6.x for consideration. It's an API change, but the current behaviour seems wrong.

Gábor Hojtsy’s picture

Status: Reviewed & tested by the community » Fixed

Ok, this fixes the return value to be as documented, so committed to Drupal 6 too.

Status: Fixed » Closed (fixed)
Issue tags: -Needs backport to D6, -node_access

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