I'm currently getting following message on all 'Administer' pages (in 6.x-dev with Garland):

notice: Trying to get property of non-object in D:\www\formdev.com\cms\modules\book\book.module on line 187.

It occurred after enabling the Book module and adding the 'Book navigation' block to the left sidebar. If I remove the book navigation block from the sidebar, the error is gone.

Here is the call stack:

	book_block() cms/modules/book/book.module at line 187	
	book_block() cms/modules/book/book.module at line 176	
	module_invoke() cms/includes/module.inc at line 450	
	module_invoke() cms/includes/module.inc at line 443	
	block_list() cms/modules/block/block.module at line 446	
	block_list() cms/modules/block/block.module at line 388	
	theme_blocks() cms/includes/theme.inc at line 1487	
	theme_blocks() cms/includes/theme.inc at line 1484	
	theme() cms/includes/theme.inc at line 591	
	theme() cms/includes/theme.inc at line 552	
	template_preprocess_page() cms/includes/theme.inc at line 1681	
	template_preprocess_page() cms/includes/theme.inc at line 1668	
	theme() cms/includes/theme.inc at line 632	
	theme() cms/includes/theme.inc at line 552	
	cms/index.php at line 36	
	cms/index.php at line 15	
	cms/indexx.php at line 10	
CommentFileSizeAuthor
#3 book-block.patch1.13 KBgábor hojtsy

Comments

scoutbaker’s picture

Using the latest D6 HEAD, I was not able to reproduce this following the steps provided. I created multiple books and book pages. I've also tried the block in both the left and right sidebars.

ktauber’s picture

... but if you look at the code in book.module (lines 183-187), you can see that $node is not initialized if the path is != 'node/123'. I'm new to Drupal, so I don't know why it occurs on my site. But IMO there is something wrong with this code.

    case 'view':
      if (arg(0) == 'node' && is_numeric(arg(1))) {
        $node = node_load(arg(1));
      }
      $current_bid = empty($node->book['bid']) ? 0 : $node->book['bid'];
gábor hojtsy’s picture

Status: Active » Needs review
StatusFileSize
new1.13 KB

The book block either works on a certain book's pages or on all pages. Unfortunately the book ID check was also done on non-book pages. Untested patch attached. I moved the current_bid code inside the node existence check so it should eliminate the non-object problem. I also did a small cleanup here, removed one temp variable which was not needed at all.

ktauber’s picture

The patch fixed the problem form me ;) Thanks

jody lynn’s picture

Status: Needs review » Reviewed & tested by the community

Tested and reviewed patch.

gábor hojtsy’s picture

Status: Reviewed & tested by the community » Fixed

Thanks for testing, committed.

Anonymous’s picture

Status: Fixed » Closed (fixed)

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