Commit 3921ea9e authored by mauritsl's avatar mauritsl
Browse files

Check recursion in Add parents action on hash instead of path, to allow non...

Check recursion in Add parents action on hash instead of path, to allow non hierarchical site structures where multiple parents may have the same path
parent 032dcea0
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -208,7 +208,7 @@ function hansel_action_add_parents_get_crumbs($arguments) {
  }
  
  $crumbs = array();
  $parent_paths = array();
  $parent_hashes = array();
  
  $modules = module_implements('hansel_get_parent');
  
@@ -216,11 +216,17 @@ function hansel_action_add_parents_get_crumbs($arguments) {
    foreach ($modules as $module) {
      $hook = "{$module}_hansel_get_parent";
      if ($parent = $hook($path)) {
        if (in_array($parent['path'], $parent_paths)) {
        // Create a hash to check recursion. The reason that we do not simply
        // check the paths is that the site structure may not be hierarchical.
        // There could be a parent item with the same path. This is often used
        // in cases where a top level item item has the same link as its first
        // child item.
        $hash = crc32($parent['path'] . $parent['title']);
        if (in_array($hash, $parent_hashes)) {
          // We are in recursion.
          break(2);
        }
        $parent_paths[] = $parent['path'];
        $parent_hashes[] = $hash;
        array_unshift($crumbs, array(
          'title' => $parent['title'],
          'href' => $parent['path'],