mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 06:05:56 +00:00
Backwards compat OldPageRedirector
Regression from f9724668807c7b946d9b8e8b31622d8dfdaf7903. Passes tests in 3.1, but fails in master due to Deprecation notices. Tests needed adjustments because OldPageRedirector::find_old_page() doesn't have the same method signature...
This commit is contained in:
parent
9ca336bea3
commit
6403be518a
@ -38,6 +38,8 @@ class OldPageRedirector extends Extension {
|
||||
* @return string|boolean False, or the new URL
|
||||
*/
|
||||
static public function find_old_page($params, $parent = null, $redirect = false) {
|
||||
$parent = is_numeric($parent) ? SiteTree::get()->byId($parent) : $parent;
|
||||
$params = (array)$params;
|
||||
$URL = Convert::raw2sql(array_shift($params));
|
||||
if (empty($URL)) { return false; }
|
||||
if ($parent) {
|
||||
|
@ -213,8 +213,9 @@ class ModelAsControllerTest extends FunctionalTest {
|
||||
$page->write();
|
||||
$page->publish('Stage', 'Live');
|
||||
|
||||
$response = ModelAsController::find_old_page('oldurl');
|
||||
$this->assertEquals('First Level',$response->Title);
|
||||
$url = OldPageRedirector::find_old_page('oldurl');
|
||||
$matchedPage = SiteTree::get_by_link($url);
|
||||
$this->assertEquals('First Level',$matchedPage->Title);
|
||||
|
||||
$page2 = new Page();
|
||||
$page2->Title = 'Second Level Page';
|
||||
@ -227,11 +228,13 @@ class ModelAsControllerTest extends FunctionalTest {
|
||||
$page2->write();
|
||||
$page2->publish('Stage', 'Live');
|
||||
|
||||
$response = ModelAsController::find_old_page('oldpage2',$page2->ParentID);
|
||||
$this->assertEquals('Second Level Page',$response->Title);
|
||||
$url = OldPageRedirector::find_old_page('oldpage2',$page2->ParentID);
|
||||
$matchedPage = SiteTree::get_by_link($url);
|
||||
$this->assertEquals('Second Level Page',$matchedPage->Title);
|
||||
|
||||
$response = ModelAsController::find_old_page('oldpage2',$page2->ID);
|
||||
$this->assertEquals(false, $response );
|
||||
$url = OldPageRedirector::find_old_page('oldpage2',$page2->ID);
|
||||
$matchedPage = SiteTree::get_by_link($url);
|
||||
$this->assertEquals(false, $matchedPage);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user