Problem/Motivation

I have a very specific jsonapi request that is failing unless I grant the user the "Administer vocabularies and terms" permission.

Steps to reproduce

I have a content type that has taxonomy fields and I'm querying that content type using jsonapi requests.

This filter works without the permission:

[country] => Array
        (
            [condition] => Array
                (
                    [path] => field_political_district_set.field_country
                    [operator] => =
                    [value] = CA
                )
        )

But this filter does not work unless I grant the permission:

   [org-group] => Array
        (
            [group] => Array
                (
                    [conjunction] => OR
                )

        )

    [field_base_id] => Array
        (
            [condition] => Array
                (
                    [path] => field_political_district_set.field_organization.field_base_id
                    [value] => 1
                    [memberOf] => org-group
                )

        )

   [country] => Array
        (
            [condition] => Array
                (
                    [path] => field_political_district_set.field_country
                    [operator] => =
                    [value] => CA
                    [memberOf] => org-group
                )

        )

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Issue fork drupal-3272235

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

lambic created an issue. See original summary.

bbrala’s picture

Status: Active » Postponed (maintainer needs more info)

Any chance you could dump the query? It might be an acces check hardening bug see: #3072384: When filtering by entity relationships in an "OR" group, if one of the relationship fields is empty, the item is improperly excluded from the data which sometimes breaks "OR" queries.

lambic’s picture

Ah yeah that sounds like what might be happening. How would I dump the query?

josmera01 made their first commit to this issue’s fork.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

quietone’s picture

Status: Postponed (maintainer needs more info) » Needs review
Issue tags: +Bug Smash Initiative

@lambic, is this still a problem? If you resolved it can add a comment on what you did. Thanks.

This looks like it needs a reply to #3. Setting back to NR for an answer.

@josmera01, Credit has been removed per How is credit granted for Drupal core issues.

smustgrave’s picture

Status: Needs review » Closed (outdated)

Closing this one out

@lambic to dump your query can use something like this

// Debug.
dump($query->execute());
dump($query->sqlQuery->__toString());

If it's a view you can go to /admin/structure/views/settings and enable Show SQL Query. Then in the View UI you'll see the query.

Third option is to see if the devel module can be used.

Thought think option1 is probably the best from what it sounds like.

If turns out different from #3072384: When filtering by entity relationships in an "OR" group, if one of the relationship fields is empty, the item is improperly excluded from the data please reopen with an explanation how it was different

Thanks!