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

Commit

Permalink
FIX, checking to ensure there's a current controller.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathan Glasl committed Jun 26, 2017
1 parent 5a589a3 commit d5b8724
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# [misdirection](https://packagist.org/packages/nglasl/silverstripe-misdirection)

_The current release is **2.2.22**_
_The current release is **2.2.23**_

> 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.
Expand Down
2 changes: 1 addition & 1 deletion code/extensions/SiteTreeMisdirectionExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function onBeforeWrite() {

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

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

// Determine whether the vanity mapping URL has been updated.
Expand Down
2 changes: 1 addition & 1 deletion code/services/MisdirectionService.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function getMapping($URL, $host = null) {

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

if(is_null($host) && ($controller = Controller::curr())) {
if(is_null($host) && Controller::has_curr() && ($controller = Controller::curr())) {
$host = $controller->getRequest()->getHeader('Host');
}
$temporary = $host;
Expand Down

0 comments on commit d5b8724

Please sign in to comment.