diff --git a/core/control/ModelAsController.php b/core/control/ModelAsController.php index 3784f9e2a..41b850d66 100755 --- a/core/control/ModelAsController.php +++ b/core/control/ModelAsController.php @@ -150,7 +150,7 @@ class ModelAsController extends Controller implements NestedController { static function find_old_page($URLSegment,$parentID = 0, $ignoreNestedURLs = false) { $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. 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. 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); - } } } \ No newline at end of file diff --git a/tests/ModelAsControllerTest.yml b/tests/ModelAsControllerTest.yml new file mode 100644 index 000000000..e69de29bb diff --git a/tests/control/ModelAsControllerTest.php b/tests/control/ModelAsControllerTest.php index 32e075604..e8bd1bdd5 100644 --- a/tests/control/ModelAsControllerTest.php +++ b/tests/control/ModelAsControllerTest.php @@ -5,6 +5,8 @@ */ class ModelAsControllerTest extends FunctionalTest { + static $fixture_file = 'sapphire/tests/ModelAsControllerTest.yml'; + protected $autoFollowRedirection = false; protected $orig = array();