diff --git a/hansel.actions.inc b/hansel.actions.inc index d014cb51a70f3aedaecb546c39f16d06c5cae469..567050e9df4b0a06b0ac87c8fea785c9ea9be122 100644 --- a/hansel.actions.inc +++ b/hansel.actions.inc @@ -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'],