diff --git a/CHANGELOG.md b/CHANGELOG.md index 9c4406b37..3b3ae8484 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -59,6 +59,7 @@ 1. [](#new) * Added support for custom `FormFlash` save locations + * Added a new `Utils::arrayLower()` method for lowercasing arrays 1. [](#improved) * Use new `Utils::getSupportedPageTypes()` to enforce `html,htm` at the front of the list [#2531](https://github.com/getgrav/grav/issues/2531) 1. [](#bugfix) @@ -70,6 +71,7 @@ * Fixed Flex User to have permissions to save and delete his own user * Fixed new Flex User creation not being possible because of username could not be given * Fixed fatal error 'Expiration date must be an integer, a DateInterval or null, "double" given' [#2529](https://github.com/getgrav/grav/issues/2529) + * Fixed non-existing Flex object having a bad media folder # v1.6.11 ## 06/21/2019 diff --git a/system/src/Grav/Common/Utils.php b/system/src/Grav/Common/Utils.php index 6a6c8bb71..0ffbfcb33 100644 --- a/system/src/Grav/Common/Utils.php +++ b/system/src/Grav/Common/Utils.php @@ -323,6 +323,17 @@ abstract class Utils return (object)array_merge((array)$obj1, (array)$obj2); } + /** + * Lowercase an entire array. Useful when combined with `in_array()` + * + * @param array $a + * @return array|false + */ + public static function arrayLower(Array $a) + { + return array_combine(array_map('strtolower', $a), $a); + } + /** * Simple function to remove item/s in an array by value * diff --git a/system/src/Grav/Framework/Flex/Traits/FlexMediaTrait.php b/system/src/Grav/Framework/Flex/Traits/FlexMediaTrait.php index ef6755fde..149f5fadb 100644 --- a/system/src/Grav/Framework/Flex/Traits/FlexMediaTrait.php +++ b/system/src/Grav/Framework/Flex/Traits/FlexMediaTrait.php @@ -49,7 +49,7 @@ trait FlexMediaTrait */ public function getStorageFolder() { - return $this->getFlexDirectory()->getStorageFolder($this->getStorageKey()); + return $this->exists() ? $this->getFlexDirectory()->getStorageFolder($this->getStorageKey()) : ''; } /** @@ -57,7 +57,7 @@ trait FlexMediaTrait */ public function getMediaFolder() { - return $this->getFlexDirectory()->getMediaFolder($this->getStorageKey()); + return $this->exists() ? $this->getFlexDirectory()->getMediaFolder($this->getStorageKey()) : ''; } /**