PHP exception "Unsupported operand types" on addCss() call with media queries

I’ve just updated a Grav install from 1.5.10 to 1.6.3 (on PHP 7.2.14) and I’m getting a PHP exception “Unsupported operand types”.

The stack trace doesn’t highlight where in my code the problem lies, but I’ve managed to track it down to several addCss() calls that include media queries:

{% do assets.addCss('theme://css/customizer-min-width-480.css', {'media':'only screen and (min-width: 480px)'}, 106) %}
{% do assets.addCss('theme://css/customizer-min-width-560.css', {'media':'only screen and (min-width: 560px)'}, 105) %}
{% do assets.addCss('theme://css/customizer-min-width-640.css', {'media':'only screen and (min-width: 640px)'}, 104) %}
{% do assets.addCss('theme://css/customizer-min-width-960.css', {'media':'only screen and (min-width: 960px)'}, 103) %}
{% do assets.addCss('theme://css/customizer-min-width-1440.css', {'media':'only screen and (min-width: 1440px)'}, 102) %}

When I delete these my site loads without issue (though obviously without the correct styling).

Am I formatting these addCss() calls properly?

Worked this out. I had to move the priority value into the options array, using the priority key:

{% do assets.addCss('theme://css/customizer-min-width-480.css', {'media':'only screen and (min-width: 480px)', 'priority': 106}) %}
{% do assets.addCss('theme://css/customizer-min-width-560.css', {'media':'only screen and (min-width: 560px)', 'priority': 105}) %}
{% do assets.addCss('theme://css/customizer-min-width-640.css', {'media':'only screen and (min-width: 640px)', 'priority': 104}) %}
{% do assets.addCss('theme://css/customizer-min-width-960.css', {'media':'only screen and (min-width: 960px)', 'priority': 103}) %}
{% do assets.addCss('theme://css/customizer-min-width-1440.css', {'media':'only screen and (min-width: 1440px)', 'priority': 102}) %}
1 Like