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
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | abc.patch | 1.18 KB | arunsahijpal |
Issue fork views_taxonomy_term_name_depth-3501376
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
Comment #2
arunsahijpal commentedWorking on it.
Comment #3
arunsahijpal commentedHi @batigolix,
I've tried this on
7.x-dev.zipon 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-devversion and this version is causion errorDrupal\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
Comment #4
arunsahijpal commentedComment #5
divyansh.gupta commentedTested 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).
Comment #6
rakesh.gectcr@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.
Comment #7
rakesh.gectcrComment #9
rakesh.gectcr