Problem with filter not working

Created on 10 June 2023, over 1 year ago
Updated 23 February 2024, 9 months ago

I have a problem with the filters.

I want the JSON content to be displayed only if there is a certain value in a field.

In the JSON file there is a field "current", which contains either yes or no.

If yes, the content should be displayed, if no, it should not.
At the filter I have the operator "is equal" with the value "yes", then it will be displayed. But it is also displayed no matter which value I enter, e.g. also with no or 1234.

With all other operators, nothing is displayed, regardless of which value I enter.

The behavior seems very strange to me, I have worked a lot with views filters.

Can anyone understand what is going on?

πŸ“Œ Task
Status

Needs review

Version

2.0

Component

Module

Created by

πŸ‡ΈπŸ‡ͺSweden markusdala Dalarna

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

Merge Requests

Comments & Activities

  • Issue created by @markusdala
  • πŸ‡ΈπŸ‡ͺSweden markusdala Dalarna
  • πŸ‡¬πŸ‡­Ghana jnrfred

    I am also having same issue with filters not working. Any value I set does not work and when I try to expose the form I get the error message
    "Error message: This identifier is not allowed."

  • πŸ‡¬πŸ‡­Ghana jnrfred

    I can confirm the filter works when viewing the saved views but does not show or work in views back-end where you are building the views. I think the issue is with core.

  • πŸ‡ͺπŸ‡ΈSpain abelcain Madrid

    There's a problem with the porting of this module to D9, at class ViewsJsonFilter the $operators are declared, and had been changed from previous version of https://www.drupal.org/project/views_json_query/releases/7.x-1.0 β†’
    So now, when reaching class ViewsJsonQuery, and processing each row, a call is made to function ops(). In this function are the same 6 elements as per D7 module, but is not including the following: 'word', 'allwords', 'startswith', 'not_starts', 'ends', 'not_ends', 'not' and 'regular_expression'...
    For us, when using that options we have a WSOD with message: "TypeError: call_user_func_array(): Argument #1 ($callback) must be a valid callback, no array or string given in call_user_func_array() (line 322 of .../web/modules/contrib/views_json_source/src/Plugin/views/query/ViewsJsonQuery.php)."

    We went then for the use of the grouping filters but we have the issue reported by the colleague in this issue. The AND/OR management at parse() function in class ViewsJsonQuery is not working for us, so we will work on this also...maybe we can deliver a patch here. As soon we get to any conclussion, we'll add an update here.

  • πŸ‡ͺπŸ‡ΈSpain abelcain Madrid

    The problem is at class ViewsJsonQuery at function parse().

    When processing first takes the filter information with

    $filter_group = $view->display_handler->getOption('filter_groups');

    Which renders this information:

    {"operator":"AND","groups":{"1":"AND","2":"OR"}}
    

    And all the processing is using the first group's data, in my case the 'AND':

    $group_conditional_operator = $filter_group['groups'][1] ?? "AND";

    The problem is that the process is prepared for 1 group only then, and when more than one group is present the 'AND' is maintained (in our case).

    We checked with this:

        $filter_handlers = $view->getHandlers('filter');
        \Drupal::messenger()->addMessage(time() . " Filter hanlers : " . "-" . rand() . json_encode($filter_handlers));

    That we have same information than the current process is using BUT it has a variable called 'group' so we can then get the data of each group and get the corresponding data. We're working on a patch to fix this issue and will provide it here soon.

  • Assigned to abelcain
  • πŸ‡ͺπŸ‡ΈSpain abelcain Madrid
  • πŸ‡ͺπŸ‡ΈSpain abelcain Madrid
  • Merge request !5Resolve #3366032 "Problem with filter" β†’ (Closed) created by abelcain
  • Issue was unassigned.
  • Status changed to Needs review about 1 year ago
  • πŸ‡ͺπŸ‡ΈSpain abelcain Madrid

    A Merge request (MR5) has been added, please do the review and after corrections, we can create an stable patch and ask the maintainer to review and merge if all is ok for him.

  • Assigned to abelcain
  • Status changed to Active about 1 year ago
  • πŸ‡ͺπŸ‡ΈSpain abelcain Madrid
  • πŸ‡ͺπŸ‡ΈSpain abelcain Madrid

    We provide a patch based on the MR5 above mentioned.

  • Issue was unassigned.
  • Status changed to Needs review about 1 year ago
  • πŸ‡ͺπŸ‡ΈSpain abelcain Madrid
Production build 0.71.5 2024