From b89b1c93f41fca3b2e3aad937effec916e9c354a Mon Sep 17 00:00:00 2001 From: Nathan Glasl Date: Fri, 17 Feb 2017 11:17:50 +1100 Subject: [PATCH] FIX, #12. --- README.md | 2 +- code/dataobjects/MediaAttribute.php | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 7fd9139..6610703 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # [mediawesome](https://packagist.org/packages/nglasl/silverstripe-mediawesome) -_The current release is **2.0.2**_ +_The current release is **2.0.3**_ > A module for SilverStripe which will allow creation of dynamic media holders/pages with CMS customisable types and attributes (blogs, events, news, publications). diff --git a/code/dataobjects/MediaAttribute.php b/code/dataobjects/MediaAttribute.php index 6fc38a4..542c8ff 100644 --- a/code/dataobjects/MediaAttribute.php +++ b/code/dataobjects/MediaAttribute.php @@ -156,10 +156,9 @@ public function onBeforeWrite() { // Retrieve the respective media type for updating all attribute references. - $parameters = Controller::curr()->getRequest()->requestVars(); + $parameters = Controller::has_curr() ? Controller::curr()->getRequest()->requestVars() : null; $matches = array(); - $result = preg_match('#TypesAttributes/item/[0-9]*/#', $parameters['url'], $matches); - if($result) { + if(is_array($parameters) && preg_match('#TypesAttributes/item/[0-9]*/#', $parameters['url'], $matches)) { $ID = preg_replace('#[^0-9]#', '', $matches[0]); $pages = MediaPage::get()->innerJoin('MediaType', 'MediaPage.MediaTypeID = MediaType.ID')->where('MediaType.ID = ' . (int)$ID);