I'm getting a fatal error that brings my site completely down for all book pages:

I've narrowed it down to _bootstrap_book_fix_theme_hooks -- if I simply return before it does anything, the error goes away and the navigation is shown albeit completely different.

It doesn't happen on a vanilla simplytest.me site and changing my site (entity, entity_view_mode, features, etc etc) to bartik also works fine.

I'm happy to work on a patch, but I'm not sure what that function is doing or why it's doing it so I was hoping maybe another pair of eyes might be able to give me a nudge in the right direction.

For ease of reference, here's the function in its entirety:

/**
 * Helper function to fix theme hooks in book TOC menus.
 *
 * @param int $bid
 *   The book identification number.
 * @param array $element
 *   The element to iterate over, passed by reference.
 * @param int $level
 *   Used internally to determine the current level of the menu.
 */
function _bootstrap_book_fix_theme_hooks($bid, array &$element, $level = 0) {
  $hook = $level === 0 ? $bid : 'sub_menu__' . $bid;
  $element['#theme_wrappers'] = array('menu_tree__book_toc__' . $hook);
  foreach (element_children($element) as $child) {
    $element[$child]['#theme'] = 'menu_link__book_toc__' . $hook;
    // Iterate through all child menu items as well.
    if (!empty($element[$child]['#below'])) {
      _bootstrap_book_fix_theme_hooks($bid, $element[$child]['#below'], ($level + 1));
    }
  }
}
CommentFileSizeAuthor
bootstrap-undefined-index-error.png153.57 KBWorldFallz
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

WorldFallz created an issue. See original summary.

WorldFallz’s picture

Issue summary: View changes
markhalliwell’s picture

Status: Active » Postponed (maintainer needs more info)

The errors are pretty self explanatory: something is being injected into the menu tree that isn't actually a link and it's fataling because NULL is passed.

Given that this works out-of-the-box, I would imagine there is some other contrib module that handles/generates menu items here?

WorldFallz’s picture

Nothing that should handle/affect book navigation that I can think of, but I'll debug deeper and see if I can find something.

But what's the purpose of this function? What does it 'fix'? And why does it need fixing?

and thanks for the quick reply!

markhalliwell’s picture

It replaces core's implementation of the #theme hook(s) invoked:
http://drupal-bootstrap.org/api/bootstrap/templates%21book%21book-naviga...

As suggestions so that they can be properly targeted:

bootstrap_menu_link__book_toc

bootstrap_menu_tree__book_toc
bootstrap_menu_tree__book_toc__sub_menu

WorldFallz’s picture

I did find one odd thing after setting deeper break points.

Line 60 of bootstrap/templates/menu/menu-link-func.php is looking for $variables['element']:

$element = $variables['element'];

but debug shows $variables['element'] doesn't exist, but $variables['elements'] does.

Changing that from "element" to "elements" stops the fatalness of the error, the page renders, the book nav renders, and I just get the notices starting from:

Notice: Undefined index: entity keys in entity_id() (line 584 of /var/www/html/dev/sites/all/modules/insite_profile/entity/entity.module).

and above. At least now I can go deeper and try and figure out what's generating them.

WorldFallz’s picture

still tracking this down. Looks to be an issue between bootstrap book outline handling and entity_menu_links module which is important to being able to export menu links with features correctly.

markhalliwell’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)

This sounds like a compatibility issue, or rather an issue with the other module more than anything.

WorldFallz’s picture

For anyone else that stumbles across this, it is the entity_menu_links module and I found a non hack workaround: #2738285: Theme hook is rendering through unexpected render element with Bootstrap.