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> git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@95902 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
d8b67c4a2e
commit
0c13c7a091
@ -386,14 +386,19 @@ class SS_HTTPRequest implements ArrayAccess {
|
||||
* @return string
|
||||
*/
|
||||
public function shiftAllParams() {
|
||||
$keys = array_keys($this->allParams);
|
||||
$values = array_values($this->allParams);
|
||||
$value = array_shift($values);
|
||||
|
||||
$keys = array_keys($this->allParams);
|
||||
$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;
|
||||
}
|
||||
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
|
@ -65,25 +65,43 @@ 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;
|
||||
}
|
||||
|
||||
|
||||
public function second_index() {
|
||||
return $this->index();
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user