BUGFIX: Fixed nested URLs operation for pages more than 4 levels deep.

From: Andrew Short <andrewjshort@gmail.com>

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@95902 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Andrew Short 2009-12-18 05:19:28 +00:00 committed by Sam Minnee
parent d8b67c4a2e
commit 0c13c7a091
2 changed files with 37 additions and 14 deletions

View File

@ -390,6 +390,11 @@ class SS_HTTPRequest implements ArrayAccess {
$values = array_values($this->allParams);
$value = array_shift($values);
// push additional unparsed URL parts onto the parameter stack
if(array_key_exists($this->unshiftedButParsedParts, $this->dirParts)) {
$values[] = $this->dirParts[$this->unshiftedButParsedParts];
}
foreach($keys as $position => $key) {
$this->allParams[$key] = isset($values[$position]) ? $values[$position] : null;
}

View File

@ -65,19 +65,37 @@ class ContentControllerTest extends FunctionalTest {
$this->assertEquals(0, $controller->ChildrenOf('/third-level/')->Count());
}
public function testDeepNestedURLs() {
SiteTree::enable_nested_urls();
$page = new Page();
$page->URLSegment = 'base-page';
$page->write();
for($i = 0; $i < 10; $i++) {
$parentID = $page->ID;
$page = new ContentControllerTest_Page();
$page->Title = "Page Level $i";
$page->URLSegment = "level-$i";
$page->write();
}
$this->assertEquals($page->Title, $this->get($page->Link())->getBody());
SiteTree::disable_nested_urls();
}
}
class ContentControllerTest_Page extends Page {
class ContentControllerTest_Page extends Page { }
class ContentControllerTest_Page_Controller extends Page_Controller {
public static $allowed_actions = array (
'second_index'
);
}
class ContentControllerTest_Page_Controller extends Page_Controller {
public function index() {
return $this->Title;
}