mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
BUGFIX: When finding an old page in the 404 handler, favour existing subpages over historical ones. (from r104468)
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@112349 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
253c27e2a8
commit
971d0f108f
@ -150,7 +150,7 @@ class ModelAsController extends Controller implements NestedController {
|
|||||||
static function find_old_page($URLSegment,$parentID = 0, $ignoreNestedURLs = false) {
|
static function find_old_page($URLSegment,$parentID = 0, $ignoreNestedURLs = false) {
|
||||||
$URLSegment = Convert::raw2sql($URLSegment);
|
$URLSegment = Convert::raw2sql($URLSegment);
|
||||||
|
|
||||||
$useParentIDFilter = SiteTree::nested_urls() && !$ignoreNestedURLs;
|
$useParentIDFilter = SiteTree::nested_urls() && $parentID;
|
||||||
|
|
||||||
// First look for a non-nested page that has a unique URLSegment and can be redirected to.
|
// First look for a non-nested page that has a unique URLSegment and can be redirected to.
|
||||||
if(SiteTree::nested_urls()) {
|
if(SiteTree::nested_urls()) {
|
||||||
@ -177,12 +177,6 @@ class ModelAsController extends Controller implements NestedController {
|
|||||||
// Run the page through an extra filter to ensure that all decorators are applied.
|
// Run the page through an extra filter to ensure that all decorators are applied.
|
||||||
if(SiteTree::get_by_link($oldPage->RelativeLink())) return $oldPage;
|
if(SiteTree::get_by_link($oldPage->RelativeLink())) return $oldPage;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise, if nested URLs is enabled, look for a page anywhere in the site that may be
|
|
||||||
// left from pre-nested-URLs days
|
|
||||||
if(SiteTree::nested_urls() && !$ignoreNestedURLs && $parentID == 0) {
|
|
||||||
return self::find_old_page($URLSegment, $parentID, true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
0
tests/ModelAsControllerTest.yml
Normal file
0
tests/ModelAsControllerTest.yml
Normal file
@ -7,6 +7,8 @@ class ModelAsControllerTest extends FunctionalTest {
|
|||||||
|
|
||||||
protected $usesDatabase = true;
|
protected $usesDatabase = true;
|
||||||
|
|
||||||
|
static $fixture_file = 'sapphire/tests/ModelAsControllerTest.yml';
|
||||||
|
|
||||||
protected $autoFollowRedirection = false;
|
protected $autoFollowRedirection = false;
|
||||||
|
|
||||||
protected $orig = array();
|
protected $orig = array();
|
||||||
|
Loading…
Reference in New Issue
Block a user