summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaurits Lawende2012-10-05 11:06:13 (GMT)
committer Maurits Lawende2012-10-05 11:06:13 (GMT)
commit3921ea9ef2d16f1e24086016331bc4da7b0859c7 (patch)
treecb53b98429e1e413b56bdca527b55a249b477d2a
parent032dcea069ab1d212a0f78d8ae625cf1cce62329 (diff)
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
-rw-r--r--hansel.actions.inc12
1 files changed, 9 insertions, 3 deletions
diff --git a/hansel.actions.inc b/hansel.actions.inc
index d014cb5..567050e 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'],