When trying to view a book page, with a book block shown on book pages only, I get the following error as an "Authenticated User" and not as an "Administrator":
PDOException: SQLSTATE[HY000]: General error: 1 ambiguous column name: nid: SELECT DISTINCT node.title AS title FROM {node} node INNER JOIN {node_access} na ON na.nid = node.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] => 16 [:db_condition_placeholder_1] => 0 [:db_condition_placeholder_2] => all [:db_condition_placeholder_3] => 10 [:db_condition_placeholder_4] => acl [:db_condition_placeholder_5] => 20 [:db_condition_placeholder_6] => content_access_author [:db_condition_placeholder_7] => 2 [:db_condition_placeholder_8] => content_access_rid [:db_condition_placeholder_9] => 1 ) in book_block_view() (line 287 of C:\xampp\htdocs\drupal\modules\book\book.module).
You will note that the string WHERE (nid = :db_condition_placeholder_0) is missing it's table specifier. This should read "node.nid" or perhaps "na.nid" instead of just "nid".
Line 287 of book.module is this: $title = $select->execute()->fetchField();
This appears to have something to do with the call $select = db_select('node'); earlier, so I've put it under "database system" rather than book.module.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | 1109852-3.patch | 738 bytes | bfroehle |
| #2 | book.module.patch | 713 bytes | adamskinner |
| #1 | book.module.patch | 713 bytes | adamskinner |
Comments
Comment #1
adamskinner commentedI did some more poking around this morning, and was able to resolve the issue. It occurred due to a lack of a table alias for the node table.
To replicate this issue, create a book and set a block for it. View the block as an administrator, and then as a regular user. The regular user will get the error above prior to the patch, and after the patch they are able to view the page.
[edit] A patch is attached, but I did it backwards. Use the subsequent one instead.
Comment #2
adamskinner commentedMy previous patch had the filenames in reverse position. The new patch reads thusly:
Comment #3
bfroehle commentedI've attached @adamskinner's patch in #2 in a format compatible with the test bot. I have not, however, reviewed the patch.
Comment #4
Anonymous (not verified) commentedI can confirm this bug is still alive and kicking on 7.2. The alias for node is missing, just that little fix. Please fix it!
Comment #5
JimmyAx commentedI suggest using #1013864: Book navigation block fails with Node Access modules as it's the original issue for this problem. The patch in #3 is outdated by now and has been updated in #1013864.