mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
BUGFIX: Fixed nested URLs operation for pages more than 4 levels deep.
From: Andrew Short <andrewjshort@gmail.com> (from r95902) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@97433 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
feabafcada
commit
46a8083e57
@ -390,6 +390,11 @@ class SS_HTTPRequest implements ArrayAccess {
|
|||||||
$values = array_values($this->allParams);
|
$values = array_values($this->allParams);
|
||||||
$value = array_shift($values);
|
$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) {
|
foreach($keys as $position => $key) {
|
||||||
$this->allParams[$key] = isset($values[$position]) ? $values[$position] : null;
|
$this->allParams[$key] = isset($values[$position]) ? $values[$position] : null;
|
||||||
}
|
}
|
||||||
|
@ -65,19 +65,37 @@ class ContentControllerTest extends FunctionalTest {
|
|||||||
$this->assertEquals(0, $controller->ChildrenOf('/third-level/')->Count());
|
$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 (
|
public static $allowed_actions = array (
|
||||||
'second_index'
|
'second_index'
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
class ContentControllerTest_Page_Controller extends Page_Controller {
|
|
||||||
|
|
||||||
public function index() {
|
public function index() {
|
||||||
return $this->Title;
|
return $this->Title;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user