Books Re-appear in all blocks
| Project: | Advanced Book Blocks |
| Version: | 6.x-1.9 |
| Component: | Code |
| Category: | bug report |
| Priority: | critical |
| Assigned: | Unassigned |
| Status: | needs review |
Jump to:
There is an issue where if the main page of a book (top level) is edited in any way then the book will re-appear on all blocks.
Simple Example to Explain: I have 3 blocks (Block1, Block2, Block3) and 3 Books (Book1, Book2, Book3). Each book is in its corresponding Block, so Block1 has only Book1 etc. I go to Book2's main page, edit something on it and click SAVE. Now Book2 appears in Block1, Block2 and Block3 not just in Block2.
I have tried with a variety of block automation settings including "Lock this block to new books" which i assume means do not add any new books to this block. No matter the settings i have for the block - the same issue above appears to occur.
Becomes painful with alot of pages within a book - as you have to manually edit what book appears on each block everytime a book page is edited.
Might be related/same issue as here: http://drupal.org/node/446408

#1
Looked through current bugs again and related to http://drupal.org/node/386960 - reading through this bug now for more info.
EDIT:
OK - more testing.
With the block automation set to "New books are disabled by default (Editing an existing book will enable it or leave it enabled" - editing a current book (main page) will add it to all blocks even if it was disabled on one of the blocks prior to editing.
With block automation set to "Lock this block to any new books" - editing a current book (main page) will remove it from any block that it appears under.
If you edit a book page with either of the above settings - it doesnt do any of the above so it seems that editing an actual book (top level page) it seems to treat it as a new book not a current book that has been modified.
This is a bit of a pain as if you edit or add any books then you have to go through and adjust all tick/untick all the books for each block.
Not sure if this is a bug with the way the books module is coded in drupal 6.x or a bug with Advanced Book Blocks - or even the intended way that ABB should work.
If this is the ended way it should work - then would this mean that we should be using the Taxonomy module to not show books in a block based on terms. This would seem a bit painful as it's just another bunch of steps you have to do to get it to work correctly. Would be nice to have a "Do Nothing" option with the block automation so that this above doesn't occur when editing a top level book, and if a new book was added, then you could enable it on the appropriate menu only.
Other than this bug - using Advanced Book Blocks and Node Privacy by Role - menus and access to the site is made very easy.
I hope some insight can be provided as this is the only thing stopping me from using this for a bunch of Portal sites for clients.
#2
Similar issue here.
1. I'm creating an ABB for each department in a university.
2. Each department/unit is a book.
3. And each department/unit has a site map page.
4. In that node I'm using PHP to display the ABB for that book. This means that in the ABB configuration settings for each block, there are 27 (or so) unticked books and one ticked book. And I have each one set to lock out new books. And I'm not using taxonomies for this.
6. And in the admin/build/blocks page, all of the ABB's are technically disabled - I'm just force-displaying them inside each book's (otherwise blank) "site map" page. As mentioned before, I do this using a simple PHP snippet.
The problem is that the ABBs are being reset automatically every now and then - meaning that they're going from having one book ticked..to having ALL of them ticked. And then nothing shows up in the respective "site map" pages for those books. I should mention that ALL of the books are not resetting at once. It appears to be the result of something being done through editing. I have 27 content managers who are working on the site...and I suspect that the 'reset' is happening either when they edit the top-most page of their book or when they use the click-drag interface of their book outline.
Whatever the case may be, the problem is that individual ABBs are being automatically reset. And I'm not sure why.
side note: if we can't get to the bottom of this automatic resetting issue, might i suggest a 'select/deselect all' feature on the ABB list page. that would lessen the time i spend clicking and clicking to correct the reset problem. it would also help when adding a new ABB.
#3
Check #585716: New book never becomes enabled automatically if any ABB use taxonomy terms as condition for possible solution
#4
I had the same problem and think I have a fix. I'm under a crazy deadline and am not AT ALL sure of my work but hope it helps. I think the problem is in recursive_book_array_builder(); I stuck some debug code in and will show that all. But the short answer... there is no test that the first query is returning a valid row. If the query returns an invalid row, some wacky stuff happens. When I trap out empty query results, the problem goes away.
Can anyone else try adding the trap and tell me if it fixes the problem? And, :-D can someone w a fresh brain tell me if that is a logical solution?
Anyway, my debug code and explanation:
<?php
function recursive_book_array_builder($nid_array) {
var_dump($nid_array);
foreach ($nid_array as $nid) {
echo '<hr>'.$nid.'<br>';
$result = db_query("SELECT n.title, n.status, b.mlid FROM {node} n, {book} b WHERE n.nid = %d AND b.nid = n.nid", $nid);
var_dump($result); echo '<br>';
$book = NULL;
while ($book = db_fetch_object($result)) {
var_dump($book); echo '<br>';
$book_title = $book->title;
$status = $book->status;
$mlid = $book->mlid;
}
// Trap out
if( empty($book_title) ) {
//continue; //UNCOMMENT THIS... DOES THE PROBLEM GO AWAY?
}
?>
and got the following (COMMENTARY ADDED IN BOLD):
array(4) { [0]=> string(2) "55" [1]=> string(2) "56" [2]=> string(2) "74" [3]=> string(2) "85" } //THERE ARE 4 TOP LEVEL BOOKS
55 //THIS BID POINTS TO A DELETED NODE
resource(344) of type (mysql result) //RESOURCE W 0 ROWS
array(1) { [0]=> string(2) "85" } //HOW DID THIS GET INTO $BOOK?!?!?!?!?!
// NOW WE RECURSE INTO BID 85
85
resource(502) of type (mysql result)
object(stdClass)#170 (3) { ["title"]=> string(18) "Archstone Richmond" ["status"]=> string(1) "1" ["mlid"]=> string(3) "835" } //ATLEAST THIS BID HAS A NODE. BUT ITS A PARENT. IT SHOULD NOT BE HERE!!!
56
resource(504) of type (mysql result)
array(1) { [0]=> string(2) "85" } 85
resource(662) of type (mysql result)
object(stdClass)#138 (3) { ["title"]=> string(18) "Archstone Richmond" ["status"]=> string(1) "1" ["mlid"]=> string(3) "835" }
74
resource(664) of type (mysql result)
array(1) { [0]=> string(2) "85" } 85
resource(822) of type (mysql result)
object(stdClass)#170 (3) { ["title"]=> string(18) "Archstone Richmond" ["status"]=> string(1) "1" ["mlid"]=> string(3) "835" }
85
resource(824) of type (mysql result)
object(stdClass)#170 (3) { ["title"]=> string(18) "Archstone Richmond" ["status"]=> string(1) "1" ["mlid"]=> string(3) "835" }
#5