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

CommentFileSizeAuthor
#3 abc.patch1.18 KBarunsahijpal
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

batigolix created an issue. See original summary.

arunsahijpal’s picture

Assigned: Unassigned » arunsahijpal

Working on it.

arunsahijpal’s picture

Status: Active » Needs review
StatusFileSize
new1.18 KB

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

arunsahijpal’s picture

Assigned: arunsahijpal » Unassigned
divyansh.gupta’s picture

Status: Needs review » Reviewed & tested by the community

Tested on Drupal 11. The patch fixes the invalid query operator issue caused by using '=' with an array — a change enforced in D11 per change record #3350985.
The patch applies cleanly and views using the contextual filter work with both single and multiple values also No database errors, and results are accurate.
Thus Marking this as Reviewed & Tested by the Community (RTBC).

rakesh.gectcr’s picture

@arunsahijpal Thank you so much for the patch, Please see the following for the patch file name format. https://www.drupal.org/docs/develop/git/using-git-to-contribute-to-drupa...

some reason I am not able to apply against the 7.x branch.

error: patch failed: src/Plugin/views/argument/IndexNameDepth.php:165                                                      ─╯
error: src/Plugin/views/argument/IndexNameDepth.php: patch does not apply
error: patch failed: views_taxonomy_term_name_depth.info.yml:2
error: views_taxonomy_term_name_depth.info.yml: patch does not apply
rakesh.gectcr’s picture

  • rakesh.gectcr committed 4797b302 on 7.x
    Issue #3501376 by arunsahijpal, batigolix, divyansh.gupta, rakesh.gectcr...
rakesh.gectcr’s picture

Version: 7.x-dev » 7.3.1
Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.