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);