diff --git a/README.md b/README.md index 329ca71..ee76745 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # [misdirection](https://packagist.org/packages/nglasl/silverstripe-misdirection) -_The current release is **2.2.25**_ +_The current release is **2.2.26**_ > A module for SilverStripe which will allow both simple and regular expression link redirections based on customisable mappings, either hooking into a page not found or replacing the default automated URL handling. diff --git a/code/dataobjects/LinkMapping.php b/code/dataobjects/LinkMapping.php index ab7ca36..8cf202d 100644 --- a/code/dataobjects/LinkMapping.php +++ b/code/dataobjects/LinkMapping.php @@ -25,7 +25,7 @@ class LinkMapping extends DataObject { ); private static $defaults = array( - 'ResponseCode' => 303 + 'ResponseCode' => 301 ); /** @@ -46,16 +46,14 @@ class LinkMapping extends DataObject { 'LinkSummary', 'Priority', 'RedirectTypeSummary', - 'RedirectPageTitle', - 'isLive' + 'RedirectPageTitle' ); private static $field_labels = array( 'MappedLink' => 'Mapping', 'LinkSummary' => 'Redirection', 'RedirectTypeSummary' => 'Redirect Type', - 'RedirectPageTitle' => 'Redirect Page Title', - 'isLive' => 'Is Live?' + 'RedirectPageTitle' => 'Redirect Page Title' ); /** diff --git a/code/extensions/MisdirectionFallbackExtension.php b/code/extensions/MisdirectionFallbackExtension.php index 24d2cf8..eff15d6 100644 --- a/code/extensions/MisdirectionFallbackExtension.php +++ b/code/extensions/MisdirectionFallbackExtension.php @@ -78,6 +78,9 @@ public function updateFields($fields) { $selection[$code] = "{$code}: {$description}"; } } + if(!$this->owner->FallbackResponseCode) { + $this->owner->FallbackResponseCode = 303; + } $fields->addFieldToTab($tab, DropdownField::create( 'FallbackResponseCode', 'Response Code', diff --git a/code/requestfilters/MisdirectionRequestFilter.php b/code/requestfilters/MisdirectionRequestFilter.php index 14ade8c..c481366 100644 --- a/code/requestfilters/MisdirectionRequestFilter.php +++ b/code/requestfilters/MisdirectionRequestFilter.php @@ -93,7 +93,7 @@ public function postRequest(SS_HTTPRequest $request, SS_HTTPResponse $response, $responseCode = $map->ResponseCode; if($responseCode == 0) { - $responseCode = 303; + $responseCode = 301; } else if(($responseCode == 301) && $map->ForwardPOSTRequest) { $responseCode = 308; diff --git a/tests/MisdirectionFunctionalTests.php b/tests/MisdirectionFunctionalTests.php index bb0e468..c215a4f 100644 --- a/tests/MisdirectionFunctionalTests.php +++ b/tests/MisdirectionFunctionalTests.php @@ -69,7 +69,7 @@ public function testRequestFilter() { // Determine whether the enforce misdirection is functioning correctly. $response = $this->get('wrong/page'); - $this->assertEquals($response->getStatusCode(), 303); + $this->assertEquals($response->getStatusCode(), 301); $this->assertEquals($response->getHeader('Location'), '/correct/page'); // The CMS module needs to be present to test page behaviour.