When updating the permissions of a book, an sloppy API usage creates duplicated entries in the book_access table:

user warning: Entrada duplicada '1-1' para la clave 'PRIMARY' query: INSERT INTO simpletest836016book_access (nid, rid, grant_view, grant_update, grant_delete) VALUES (1, 1, 1, 1, 1) in 

Also, when viewing a book page, a mysql error is generated when trying to verify if user has permissions to add child pages. As in the other, the testcase will include test for these errors.

As both are database errors, I've created an issue for them. This patch fixes both (the test case includes tests for both errors too).

Comments

ilo’s picture

I've modified the book_access_nodeapi() function to improve its performance also.

By the way, what is the purpose of line 211: $node->book['depth'] < MENU_MAX_DEPTH ?? should not this be controlled by the book module?

ilo’s picture

Title: Erros updating permissions for a book, or viewing a book page with permissions to create a child page. » Error viewing a book page with permissions to create a child page (hook_nodeapi issues).
StatusFileSize
new1.3 KB

I just found enough changes for the API usage to have its own patch, so I'm reverting this patch to only hook_nodeapi issues (forget previous).

This patch fixes the database query error and keep performance improvements for hook_nodeapi call.

Note: I promise, no more patch updates for this issue ;)

avpaderno’s picture

Title: Error viewing a book page with permissions to create a child page (hook_nodeapi issues). » Error viewing a book page with permissions to create a child page (hook_nodeapi() issues)
Status: Needs review » Fixed

The code has been changed, and committed in CVS.

Status: Fixed » Closed (fixed)

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