diff --git a/wire/modules/PagePathHistory.module b/wire/modules/PagePathHistory.module index 1bf65bd5..1ffdeeaa 100644 --- a/wire/modules/PagePathHistory.module +++ b/wire/modules/PagePathHistory.module @@ -389,7 +389,6 @@ class PagePathHistory extends WireData implements Module, ConfigurableModule { * @param Page $page * @param string|array $path * @param array $options - * * @return array * */ @@ -459,6 +458,13 @@ class PagePathHistory extends WireData implements Module, ConfigurableModule { * */ protected function getVirtualHistoryParent(Page $page, $pageName, array $pagePathInfo, Page $parent, array $options) { + + static $levels = array(); + + // prevent duplicate recursive calls + $levelKey = "$page->id!$pageName"; + if(isset($levels[$levelKey])) return array(); + $levels[$levelKey] = true; $paths = array(); @@ -479,7 +485,16 @@ class PagePathHistory extends WireData implements Module, ConfigurableModule { foreach($pageNamesDates as $name => $date) { // iterate through all possible parent paths - foreach($parentPaths as $parentPathInfo) { + foreach($parentPaths as $parentPathKey => $parentPathInfo) { + + /* + * @todo determine if this should be applied + if(strpos($parentPathInfo['path'], $pagePathInfo['path']) === 0) { + // disallow URLs where parent URL is child of page that has the parent + unset($parentPaths[$parentPathKey]); + continue; + } + */ $parentPath = $options['verbose'] ? $parentPathInfo['path'] : $parentPathInfo; @@ -519,6 +534,8 @@ class PagePathHistory extends WireData implements Module, ConfigurableModule { } } + unset($levels[$levelKey]); + return $paths; }