diff --git a/modules/global/src/com/haulmont/cuba/core/global/GlobalConfig.java b/modules/global/src/com/haulmont/cuba/core/global/GlobalConfig.java index 27fe88ebd5..bbe9d061e0 100644 --- a/modules/global/src/com/haulmont/cuba/core/global/GlobalConfig.java +++ b/modules/global/src/com/haulmont/cuba/core/global/GlobalConfig.java @@ -211,4 +211,11 @@ public interface GlobalConfig extends Config { @DefaultBoolean(false) boolean getUserSessionLogEnabled(); void setUserSessionLogEnabled(boolean enabled); + + /** + * @return whether the new (since 6.7) behavior regarding session parameters in query filter is enabled + */ + @Property("cuba.enableSessionParamsInQueryFilter") + @DefaultBoolean(true) + boolean getEnableSessionParamsInQueryFilter(); } \ No newline at end of file diff --git a/modules/global/src/com/haulmont/cuba/core/global/filter/QueryFilter.java b/modules/global/src/com/haulmont/cuba/core/global/filter/QueryFilter.java index c2d9175c25..3456ebdc06 100644 --- a/modules/global/src/com/haulmont/cuba/core/global/filter/QueryFilter.java +++ b/modules/global/src/com/haulmont/cuba/core/global/filter/QueryFilter.java @@ -16,9 +16,7 @@ */ package com.haulmont.cuba.core.global.filter; -import com.haulmont.cuba.core.global.QueryTransformer; -import com.haulmont.cuba.core.global.QueryTransformerFactory; -import com.haulmont.cuba.core.global.TemplateHelper; +import com.haulmont.cuba.core.global.*; import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.text.StrBuilder; import org.dom4j.Element; @@ -27,6 +25,9 @@ import java.util.*; public class QueryFilter extends FilterParser { + protected boolean enableSessionParams = AppBeans.get(Configuration.class) + .getConfig(GlobalConfig.class).getEnableSessionParamsInQueryFilter(); + public QueryFilter(Condition condition) { super(condition); } @@ -101,18 +102,22 @@ public class QueryFilter extends FilterParser { if (declaredParams.isEmpty()) return true; - - // Return true only if declared params have values and there is at least one non-session parameter among them. - // This is necessary to exclude generic filter conditions that contain only session parameters. Otherwise - // there is no way to handle exclusion. Unfortunately this imposes the restriction on custom filters design: - // condition with session-only parameters must be avoided, they must be coded as part of main query body or as - // part of another condition. - boolean found = false; - for (ParameterInfo paramInfo : declaredParams) { - if (params.contains(paramInfo.getName())) { - found = found || !paramInfo.getType().equals(ParameterInfo.Type.SESSION); + if (enableSessionParams) { + return declaredParams.stream() + .allMatch(paramInfo -> params.contains(paramInfo.getName())); + } else { + // Return true only if declared params have values and there is at least one non-session parameter among them. + // This is necessary to exclude generic filter conditions that contain only session parameters. Otherwise + // there is no way to handle exclusion. Unfortunately this imposes the restriction on custom filters design: + // condition with session-only parameters must be avoided, they must be coded as part of main query body or as + // part of another condition. + boolean found = false; + for (ParameterInfo paramInfo : declaredParams) { + if (params.contains(paramInfo.getName())) { + found = found || !paramInfo.getType().equals(ParameterInfo.Type.SESSION); + } } + return found; } - return found; } } \ No newline at end of file