The Position of the current facet's field in de queries conditions is wrongly calculated

Created on 14 February 2023, over 1 year ago

Problem/Motivation

From code:

         // When the operator is "or":
          // - For a facet with one of the elements checked, the results of
          // this facet are equal to those of the query without
          // the filter of the latter.
          // - For facets with none of the elements checked, the results are
          // those of the existing aggregation.
          $position = $this->inArrayRecursive($key, $conditions);

The calculation of this position is calculated wrongly.
This results in a wrong count of results in a facet item, when you have at least one active facet.

Steps to reproduce

It is only possible to reproduce if you have a facet in a view with both standard filters and contextual filters.
When you then have an active facet, the query contains 3 condition(group)s.
0 => the standard filters of the view
1 => the contextual filters of the view
2 => the active facet.

Because of the wrong code in the method inArrayRecursive, the found position of the facet is 1 (instead of 2), and therefor the contextual filter is ignored in the calculation of the result amount, instead of the active facet.

Proposed resolution

Rewrite the method.
I have a patch that did the job for my project, but it is actually still incorrect.

Remaining tasks

Further work out the method.
Theoretically: If you have 3 conditiongroups, and the first one contains more then 1 standard filter, but the facet uses the same field as one of the standard filters, the first conditiongroup will be passed as position, resulting in de ignorance of that first group.
To be further investigated if it is actually applicable and if so, rectify the code.

πŸ› Bug report
Status

Active

Component

Code

Created by

πŸ‡§πŸ‡ͺBelgium Tim Lammar

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024