Access control doesnt work with book. How can i fix it or will this feature be added in upcoming updates?

Comments

good_man’s picture

I tried it with book, it's working great, hmmm any more details of how to reproduce it? and what's going wrong? more details means quicker fix.

good_man’s picture

Status: Active » Postponed (maintainer needs more info)
joemaine’s picture

Category: feature » bug

I think I can define the issue between AC and Book. Book pages appear OK without AC. Book pages appear OK with AC and with the Book Navigation Block disabled - or with the Book navigation block display set to "Show block on all pages ". If "Show block only on book pages" is selected...errors occur. Here's what I find on a site when trying to access a "book" page with the Book navigation block set to Show block only on book pages:

Additional uncaught exception thrown while handling exception.

Original

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'nid' in where clause is ambiguous: SELECT DISTINCT n.title AS title FROM {node} n INNER JOIN {node_access} na ON na.nid = n.nid WHERE (nid = :db_condition_placeholder_0) AND(( (na.gid = :db_condition_placeholder_1) AND (na.realm = :db_condition_placeholder_2) )OR( (na.gid = :db_condition_placeholder_3) AND (na.realm = :db_condition_placeholder_4) )OR( (na.gid = :db_condition_placeholder_5) AND (na.realm = :db_condition_placeholder_6) ))AND (na.grant_view >= :db_condition_placeholder_7) ; Array ( [:db_condition_placeholder_0] => 2 [:db_condition_placeholder_1] => 0 [:db_condition_placeholder_2] => all [:db_condition_placeholder_3] => 0 [:db_condition_placeholder_4] => content_access_author [:db_condition_placeholder_5] => 1 [:db_condition_placeholder_6] => content_access_rid [:db_condition_placeholder_7] => 1 ) in book_block_view() (line 286 of /home3//public_html/modules/book/book.module).

Additional

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'nid' in where clause is ambiguous: SELECT DISTINCT n.title AS title FROM {node} n INNER JOIN {node_access} na ON na.nid = n.nid WHERE (nid = :db_condition_placeholder_0) AND(( (na.gid = :db_condition_placeholder_1) AND (na.realm = :db_condition_placeholder_2) )OR( (na.gid = :db_condition_placeholder_3) AND (na.realm = :db_condition_placeholder_4) )OR( (na.gid = :db_condition_placeholder_5) AND (na.realm = :db_condition_placeholder_6) ))AND (na.grant_view >= :db_condition_placeholder_7) ; Array ( [:db_condition_placeholder_0] => 2 [:db_condition_placeholder_1] => 0 [:db_condition_placeholder_2] => all [:db_condition_placeholder_3] => 0 [:db_condition_placeholder_4] => content_access_author [:db_condition_placeholder_5] => 1 [:db_condition_placeholder_6] => content_access_rid [:db_condition_placeholder_7] => 1 ) in book_block_view() (line 286 of /home3//public_html/modules/book/book.module).

kmulford1’s picture

I received the same SQL error as joemaine. I have the content access module configured to allow all authenticated roles (both the default and a couple of custom roles) to view any node with a content type of 'book'. If I'm viewing a restricted node as a user with an administrator role, I'm able to interact with all of the pages without issue. However, if I log in with a user account assigned to my non-administrator role, I get the SQL below. I do have the Book Navigation block set to display on book pages only.

As a workaround, I've enabled the Book Navigation block on all pages, then restricted the view of that block to the appropriate roles (in the block configuration area), and that seems to have done the trick.

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'nid' in where clause is ambiguous: SELECT DISTINCT n.title AS title FROM {node} n INNER JOIN {node_access} na ON na.nid = n.nid WHERE (nid = :db_condition_placeholder_0) AND(( (na.gid = :db_condition_placeholder_1) AND (na.realm = :db_condition_placeholder_2) )OR( (na.gid = :db_condition_placeholder_3) AND (na.realm = :db_condition_placeholder_4) )OR( (na.gid = :db_condition_placeholder_5) AND (na.realm = :db_condition_placeholder_6) )OR( (na.gid = :db_condition_placeholder_7) AND (na.realm = :db_condition_placeholder_8) ))AND (na.grant_view >= :db_condition_placeholder_9) ; Array ( [:db_condition_placeholder_0] => 26 [:db_condition_placeholder_1] => 0 [:db_condition_placeholder_2] => all [:db_condition_placeholder_3] => 70 [:db_condition_placeholder_4] => content_access_author [:db_condition_placeholder_5] => 2 [:db_condition_placeholder_6] => content_access_rid [:db_condition_placeholder_7] => 4 [:db_condition_placeholder_8] => content_access_rid [:db_condition_placeholder_9] => 1 ) in book_block_view() (line 286 of /var/www/vhosts/example.com/httpdocs/modules/book/book.module).

good_man’s picture

First please post code inside code tags, second thing I can't reproduce this, are you using the latest Drupal? please write a good how-to reproduce with Drupal core & content access versions number.

kmulford1’s picture

I went back to follow the same steps that I'd previously taken after updating to Drupal 7.7 and Content Access 7.x-1.2-beta1. I was unable to recreate and everything worked perfectly. I know I'm not the only one who reported this but I'd mark it closed. Thanks and sorry for not providing more specific steps previously, but it's a moot point for me now.

Mark Nielsen’s picture

I can confirm I'm this error.

I have Drupal 7.7 installed, and Content Access 7.x-1.2-beta1. I had previously installed Book Access, but found that this also had a "show-stopping" bug. So I disabled and completely uninstalled Book Access and Installed Content Access instead.

  • I have just one book so far, and I've enabled the Book block to "Show block only on book pages".
  • Using Content Access, I have set book pages in general to be inaccessible to anonymous and authenticated users. They're only viewable by a couple of specific roles which I've set up.
  • Then, through the "Access Control" tab on the top-level node in my book, I've ticked the boxes to enable anonymous and authenticated users to also "View any book content"*
  • Now, if users without the "administer nodes" permission try to view the page, they get the following error message:
    PDOException</em>: SQLSTATE[23000]: Integrity constraint violation: 1052 Column &#039;nid&#039; in where clause is ambiguous: SELECT DISTINCT n.title AS title
    FROM 
    {node} n
    INNER JOIN {node_access} na ON na.nid = n.nid
    WHERE  (nid = :db_condition_placeholder_0) AND(( (na.gid = :db_condition_placeholder_1) AND (na.realm = :db_condition_placeholder_2) )OR( (na.gid = :db_condition_placeholder_3) AND (na.realm = :db_condition_placeholder_4) )OR( (na.gid = :db_condition_placeholder_5) AND (na.realm = :db_condition_placeholder_6) )OR( (na.gid = :db_condition_placeholder_7) AND (na.realm = :db_condition_placeholder_8) )OR( (na.gid = :db_condition_placeholder_9) AND (na.realm = :db_condition_placeholder_10) )OR( (na.gid = :db_condition_placeholder_11) AND (na.realm = :db_condition_placeholder_12) ))AND (na.grant_view &gt;= :db_condition_placeholder_13) ; Array
    (
        [:db_condition_placeholder_0] =&gt; 23
        [:db_condition_placeholder_1] =&gt; 0
        [:db_condition_placeholder_2] =&gt; all
        [:db_condition_placeholder_3] =&gt; 25
        [:db_condition_placeholder_4] =&gt; content_access_author
        [:db_condition_placeholder_5] =&gt; 2
        [:db_condition_placeholder_6] =&gt; content_access_rid
        [:db_condition_placeholder_7] =&gt; 5
        [:db_condition_placeholder_8] =&gt; content_access_rid
        [:db_condition_placeholder_9] =&gt; 6
        [:db_condition_placeholder_10] =&gt; content_access_rid
        [:db_condition_placeholder_11] =&gt; 7
        [:db_condition_placeholder_12] =&gt; content_access_rid
        [:db_condition_placeholder_13] =&gt; 1
    )
     in book_block_view() (line 286 of /.../.../.../.../.../.../modules/book/book.module).
    

    Also, loading of the page partially fails, so that under this error message, Drupal reports, "The website encountered an unexpected error. Please try again later."

* I think "View any book content" is a confusing title as it made me wonder if I was updating Access Control for this specific node, or for the Book Page content type generally. But this is perhaps another (much less critical) issue :)

kenianbei’s picture

I can also confirm this, The fatal error happens when the book block is enabled.

kenianbei’s picture

Also wanted to add that any users with 'Bypass content access control' perm will not get this error.

wipeout_dude’s picture

subscribing with the same error..

david@thrale.com’s picture

Version: 7.x-1.x-dev » 7.x-1.2-beta1

I also get this problem for anonymous users only. The workaround is to select "Show block on all pages" and then under VisibilitySettings, choose the Content Types tab and select "Book". This has the same effect and it eliminates the errors.

gisle’s picture

Issue summary: View changes
Status: Postponed (maintainer needs more info) » Closed (outdated)