diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c1c2c4af1..287c860d67 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ * Added `Pages::setCheckMethod()` method to override page configuration in Admin Plugin 1. [](#bugfix) * Fixed `$grav['route']` from being modified when the route instance gets modified + * Fixed Assets options array mixed with standalone priority [#2477](https://github.com/getgrav/grav/issues/2477) # v1.6.8 ## 04/23/2019 diff --git a/system/src/Grav/Common/Assets/Traits/LegacyAssetsTrait.php b/system/src/Grav/Common/Assets/Traits/LegacyAssetsTrait.php index ccf9da2988..229c2abae7 100644 --- a/system/src/Grav/Common/Assets/Traits/LegacyAssetsTrait.php +++ b/system/src/Grav/Common/Assets/Traits/LegacyAssetsTrait.php @@ -24,19 +24,21 @@ protected function unifyLegacyArguments($args, $type = Assets::CSS_TYPE) // First argument is always the asset array_shift($args); - if (\count($args) === 0) { + if (count($args) === 0) { return []; } - if (\count($args) === 1 && \is_array($args[0])) { + // New options array format + if (count($args) === 1 && is_array($args[0])) { return $args[0]; } + // Handle obscure case where options array is mixed with a priority + if (count($args) === 2 && is_array($args[0]) && is_int($args[1])) { + $arguments = $args[0]; + $arguments['priority'] = $args[1]; + return $arguments; + } switch ($type) { - case(Assets::INLINE_CSS_TYPE): - $defaults = ['priority' => null, 'group' => null]; - $arguments = $this->createArgumentsFromLegacy($args, $defaults); - break; - case(Assets::JS_TYPE): $defaults = ['priority' => null, 'pipeline' => true, 'loading' => null, 'group' => null]; $arguments = $this->createArgumentsFromLegacy($args, $defaults); @@ -55,6 +57,11 @@ protected function unifyLegacyArguments($args, $type = Assets::CSS_TYPE) break; + case(Assets::INLINE_CSS_TYPE): + $defaults = ['priority' => null, 'group' => null]; + $arguments = $this->createArgumentsFromLegacy($args, $defaults); + break; + default: case(Assets::CSS_TYPE): $defaults = ['priority' => null, 'pipeline' => true, 'group' => null, 'loading' => null];