When you edit the handbook that is associated with a group, the parent of the top node in the book (that gets automatically created for use within the group) gets changed to the node entry itself.

Having the node value matching the parent value segfaults apache when you click on the handbook to view it later. I'm trying to look through the code in the book module to see where all parent is used and to treat matching entries the same as if the parent was 0 (top level book) but haven't had much success yet. I haven't hit on a search term that finds any thread about this. Is there a patch available to book.module that fixes this? I've applied the patch that came with the module.

Thanks.

Comments

william haller’s picture

Modifying the book module to change the parent module to 0 whenever the parent and node match seems to fix the segfaults and has fewer spots to patch than having to modify all places where the parent field is referenced.

Souvent22’s picture

Version: 4.6.x-1.x-dev » 4.7.x-1.x-dev
Component: Code » OG Views

Could you post your patch for this ? I think I'm running into the same problem.

Souvent22’s picture

Version: 4.7.x-1.x-dev » 4.6.x-1.x-dev
Component: OG Views » OG Book
JohnG-1’s picture

I think my (4.6) problem might be related (I don't really know what a segfault is) ...

when users do not have 'create book' permission, but can edit the auto-generated book pages through og admin, the 'top level' option in the book parent selection list is hidden from the user. The selector defaults to the first bookpage that the user does have access to and on submit, changes the parent of the page. Imagine the confusion that causes!

my workaround was to make an (og-public) book page called 'group handbooks' and make sure it's at the top of the book hierarchy list so it is the default parent. This is a rough and ugly solution but may be useful as a stop-gap until a proper fix can be found.

number6’s picture

Component: OG Book » og.module

There is also another bug-thread about this issue:
http://drupal.org/node/67888

However it just includes same questions. There is a bug in og_book - and it would be great if somebody already familiar with og/og_book could fix it.

moshe weitzman’s picture

Status: Active » Closed (fixed)

og_book has no maintainer, has no projecthere at drupal.org, and 4.6 is unmaintained anyway.

tormu’s picture

Here's a fix I made for this, feel free to correct, but with loose testing it seems to work..

Since the $node->parent seems to be blank whenever editing the node, I replaced it with a result from a query, on book-table there is the parent for every node.


function og_book_form_alter($form_id, &$form) {
  global $og_book_options;
  //Added below//
  $nodeId = arg(1);
  $sql = "SELECT parent FROM {book} WHERE nid = $nodeId LIMIT 1";
  $parent = db_result(db_query($sql));
  //Added above//

  $group_node = og_get_group_context();
  if ($form_id == 'book_node_form' && $group_node) {
    og_book_get_options($group_node->nid);

    $form['parent'] = array(
      '#type' => 'select', 
      '#title' => t('Parent'), 
      '#default_value' => $parent ? $parent : arg(4),
      //The old one commented out:  '#default_value' => ($node->parent ? $node->parent : arg(4)), 
      '#options' => $og_book_options,
      '#weight' => -4,
      '#description' => t('The parent that this page belongs in.')
      );
  }
}

Chaos_Zeus’s picture

The code above doesn't see, to work for me in 4.7. Is it for 4.6x? The part that appears to fail is the arg() statements. I looked briefly in the API but as the documentation says, the arg() function isnt all that clear. I think the intent is to get the node id from the referring url?

I am having terrible times with the og_book.

tormu’s picture

Status: Closed (fixed) » Fixed

No idea why wouldn't arg() work for 4.7, and that patch was made for 4.7 installation indeed. The arg() just gets the part of the drupal path, for example if the path is "node/56", arg(0) returns "node" and arg(1) returns "56".

Anyway, this patch seems to be having some problems - for some reason the parent that query returns gives the wrong node ID, so I decided to go for a better solution..

Just get rid of the whole three lines between those //Added-comments and replace them with this one and it should work: $parent = $form['parent']['#default_value']);

Veggieryan’s picture

Version: 4.6.x-1.x-dev » 4.7.x-1.x-dev

does not work for me in 4.7. og_book seems helplessly broken.

Anonymous’s picture

Status: Fixed » Closed (fixed)