Skip to content
This repository was archived by the owner on Jan 10, 2021. It is now read-only.

Commit d5b8724

Browse files
author
Nathan Glasl
committed
FIX, checking to ensure there's a current controller.
1 parent 5a589a3 commit d5b8724

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# [misdirection](https://packagist.org/packages/nglasl/silverstripe-misdirection)
22

3-
_The current release is **2.2.22**_
3+
_The current release is **2.2.23**_
44

55
> 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.
66

code/extensions/SiteTreeMisdirectionExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function onBeforeWrite() {
5252

5353
// Retrieve the vanity mapping URL, where this is only possible using the POST variable.
5454

55-
$vanityURL = (is_null($controller = Controller::curr()) || is_null($URL = $controller->getRequest()->postVar('VanityURL'))) ? $this->owner->VanityMapping()->MappedLink : $URL;
55+
$vanityURL = (!Controller::has_curr() || is_null($controller = Controller::curr()) || is_null($URL = $controller->getRequest()->postVar('VanityURL'))) ? $this->owner->VanityMapping()->MappedLink : $URL;
5656
$mappingExists = $this->owner->VanityMapping()->exists();
5757

5858
// Determine whether the vanity mapping URL has been updated.

code/services/MisdirectionService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public function getMapping($URL, $host = null) {
8282

8383
// Enforce any hostname restriction that may have been defined.
8484

85-
if(is_null($host) && ($controller = Controller::curr())) {
85+
if(is_null($host) && Controller::has_curr() && ($controller = Controller::curr())) {
8686
$host = $controller->getRequest()->getHeader('Host');
8787
}
8888
$temporary = $host;

0 commit comments

Comments
 (0)