Colormap variable substitution not working if multiple layers are provided in WMS call

Description

The issue is related to cql expressions in the rastersymbolizer style element to make the color map dynamic as described here: http://docs.geoserver.org/2.8.x/en/user/styling/sld-reference/rastersymbolizer.html#cql-expressions

It works basically, but as soon as more than one layer are passed through the layers-parameter in a WMS call the cql parameters are ignored and the defined default values are applied.

As an example, the threshold1-parameter in the following WMS call is completely ignored because two layers are passed:
http://server:8080/geoserver/prog/wms?service=WMS&version=1.1.0&request=GetMap&layers=layer_1,layer_raster&ENV=threshold1:0&styles=&bbox=8..,48..,8..,48..&width=767&height=768&srs=EPSG:4326&format=application/openlayers

The issue was confirmed in the GeoServer user group:
http://osgeo-org.1560.x6.nabble.com/Variable-substitution-not-working-if-multiple-layers-are-provided-in-WMS-call-td5271011.html

Environment

None

Status

Assignee

Andrea Aime

Reporter

M

Triage

None

Fix versions

Affects versions

Components

Priority

High
Configure