Calling Drupal\Core\Database\Query\Condition::condition() without an array compatible operator is not supported

Created on 22 January 2025, 14 days ago

Problem/Motivation

I patched views_taxonomy_term_name_depth so that I can use it on my Drupal 11 wbsite.

When running views_taxonomy_term_name_depth on Drupal 11 I get the following error:

The website encountered an unexpected error. Try again later.

Drupal\Core\Database\InvalidQueryException: Calling Drupal\Core\Database\Query\Condition::condition() without an array compatible operator is not supported. See https://www.drupal.org/node/3350985 in Drupal\Core\Database\Query\Condition->condition() (line 115 of core/lib/Drupal/Core/Database/Query/Condition.php).
Drupal\views_taxonomy_term_name_depth\Plugin\views\argument\IndexNameDepth->query() (Line: 1171)
Drupal\views\ViewExecutable->_buildArguments() (Line: 1327)
Drupal\views\ViewExecutable->build() (Line: 1451)
Drupal\views\ViewExecutable->execute() (Line: 1514)

See https://www.drupal.org/node/3350985

In src/Plugin/views/argument/IndexNameDepth.php the operator is chosen based on the amount of items available:

$operator = (count($break->value) > 1) ? 'IN' : '=';

If there is 1 item then the operator is '='. This is not allowed in D11

🐛 Bug report
Status

Active

Version

7.0

Component

Code

Created by

🇳🇱Netherlands batigolix Utrecht

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

Comments & Activities

  • Issue created by @batigolix
  • 🇮🇳India arunsahijpal

    Working on it.

  • 🇮🇳India arunsahijpal

    Hi @batigolix,
    I've tried this on 7.x-dev.zip on D11 site, as we have to choose the operators according to the amount of items available so I've modified the code with appropriate checks with testing. I am providing a patch which you can test.

    Just to know that this issue repo has a file which is not there in 7.x-dev version and this version is causion error
    Drupal\Component\Plugin\Exception\PluginException: Plugin (taxonomy_index_name_depth) instance class "Drupal\views_taxonomy_term_name_depth\Plugin\views\argument\IndexNameDepth" does not exist. in Drupal\Component\Plugin\Factory\DefaultFactory::getPluginClass() (line 97 of /app/web/core/lib/Drupal/Component/Plugin/Factory/DefaultFactory.php).

    pls check this also

    Thanks,
    Arun

Production build 0.71.5 2024