diff --git a/CHANGELOG.md b/CHANGELOG.md index 67de5995c..33218656b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,6 +42,7 @@ * Fixed checking ACL for another user (who is not currently logged in) in a Flex Object or Directory * Fixed bug in Windows where `Filesystem::dirname()` returns backslashes * Fixed Flex object issues in Windows [#2773](https://github.com/getgrav/grav/issues/2773) + * Fixed `Cannot use a scalar value as an array` error in `Utils::arrayUnflattenDotNotation()`, ignore nested structure instead # v1.7.0-rc.2 ## 12/04/2019 diff --git a/composer.lock b/composer.lock index de0100a15..6d96f8e9c 100644 --- a/composer.lock +++ b/composer.lock @@ -953,16 +953,16 @@ }, { "name": "matthiasmullie/path-converter", - "version": "1.1.2", + "version": "1.1.3", "source": { "type": "git", "url": "https://github.com/matthiasmullie/path-converter.git", - "reference": "5e4b121c8b9f97c80835c1d878b0812ba1d607c9" + "reference": "e7d13b2c7e2f2268e1424aaed02085518afa02d9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/matthiasmullie/path-converter/zipball/5e4b121c8b9f97c80835c1d878b0812ba1d607c9", - "reference": "5e4b121c8b9f97c80835c1d878b0812ba1d607c9", + "url": "https://api.github.com/repos/matthiasmullie/path-converter/zipball/e7d13b2c7e2f2268e1424aaed02085518afa02d9", + "reference": "e7d13b2c7e2f2268e1424aaed02085518afa02d9", "shasum": "" }, "require": { @@ -998,7 +998,7 @@ "paths", "relative" ], - "time": "2018-10-25T15:19:41+00:00" + "time": "2019-02-05T23:41:09+00:00" }, { "name": "maximebf/debugbar", diff --git a/system/src/Grav/Common/Utils.php b/system/src/Grav/Common/Utils.php index 6ea79a2ab..0f6839d78 100644 --- a/system/src/Grav/Common/Utils.php +++ b/system/src/Grav/Common/Utils.php @@ -1045,7 +1045,7 @@ abstract class Utils */ public static function arrayFlatten($array) { - $flatten = array(); + $flatten = []; foreach ($array as $key => $inner) { if (is_array($inner)) { foreach ($inner as $inner_key => $value) { @@ -1081,7 +1081,17 @@ abstract class Utils } /** - * Opposite of flatten, convert flat dot notation array to multi dimensional array + * Opposite of flatten, convert flat dot notation array to multi dimensional array. + * + * If any of the parent has a scalar value, all children get ignored: + * + * admin.pages=true + * admin.pages.read=true + * + * becomes + * + * admin: + * pages: true * * @param array $array * @param string $separator @@ -1098,8 +1108,20 @@ abstract class Utils if ($k === 0) { continue; } + + // Cannot use a scalar value as an array + if (null !== $last && !is_array($last)) { + continue 2; + } + $last = &$last[$dot]; } + + // Cannot use a scalar value as an array + if (null !== $last && !is_array($last)) { + continue; + } + $last = $value; } else { $newArray[$key] = $value;