Getting an error:

TypeError: Illegal offset type in isset or empty in Drupal\taxonomy\Plugin\views\filter\TaxonomyIndexTid->validateExposed() (line 353 of /code/web/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php)

Which I am able to fix by applying changes in the mentioned TaxonomyIndexTid class:

-    if ($this->options['is_grouped'] && isset($this->options['group_info']['group_items'][$input])) {
+    if ($this->options['is_grouped'] && is_string($input) && isset($this->options['group_info']['group_items'][$input])) {

As Drupal 9 is fully Composer-based so changes get override time to time. Also I created a patch that also not working for me patch link

Can you add these changes for while update code these change will consider in release.

Issue fork drupal-3336222

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

pankaj1390 created an issue. See original summary.

cilefen’s picture

Priority: Critical » Major
Status: Active » Postponed (maintainer needs more info)
Issue tags: +Needs steps to reproduce

Thanks for the report. We require the steps to reproduce for bugs to understand if there is missing test coverage.

cilefen’s picture

  • Why specifically is $input not a string in this case?
  • Can we get a stack trace too please?
pankaj1390’s picture

Because $input is the variable to contain value

I m using taxonomies in the page when open page it through error

Being for now can you create a patch and do let me till you review it. So for now I get this working

pankaj1390’s picture

StatusFileSize
new666 bytes

Creating a patch

pankaj1390’s picture

StatusFileSize
new887 bytes
smulvih2’s picture

I am running into this error on a site after upgrading from drupal/core 9.3.22 to 9.5.8. The page where this error happens is a view page, pretty straightforward setup, view based on content, with a taxonomy filter:

Configure filter criterion: Content: Has taxonomy term -> Is none of -> [term_name]

Patch #6 fixes the issue for me on this view page.

Here is error with backtrace:

The website encountered an unexpected error. Please try again later.
TypeError: Illegal offset type in isset or empty in Drupal\taxonomy\Plugin\views\filter\TaxonomyIndexTid->validateExposed() (line 353 of core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php).

Drupal\taxonomy\Plugin\views\filter\TaxonomyIndexTid->validateExposed(Array, Object) (Line: 169)
Drupal\views\Form\ViewsExposedForm->validateForm(Array, Object)
call_user_func_array(Array, Array) (Line: 82)
Drupal\Core\Form\FormValidator->executeValidateHandlers(Array, Object) (Line: 275)
Drupal\Core\Form\FormValidator->doValidateForm(Array, Object, 'views_exposed_form') (Line: 118)
Drupal\Core\Form\FormValidator->validateForm('views_exposed_form', Array, Object) (Line: 69)
Drupal\autosave_form\Form\AutosaveFormValidator->validateForm('views_exposed_form', Array, Object) (Line: 591)
Drupal\Core\Form\FormBuilder->processForm('views_exposed_form', Array, Object) (Line: 144)
Drupal\autosave_form\Form\AutosaveFormBuilder->processForm('views_exposed_form', Array, Object) (Line: 323)
Drupal\Core\Form\FormBuilder->buildForm('\Drupal\views\Form\ViewsExposedForm', Object) (Line: 97)
Drupal\autosave_form\Form\AutosaveFormBuilder->buildForm('\Drupal\views\Form\ViewsExposedForm', Object) (Line: 134)
Drupal\views\Plugin\views\exposed_form\ExposedFormPluginBase->renderExposedForm() (Line: 1243)
Drupal\views\ViewExecutable->build() (Line: 392)
Drupal\views\Plugin\views\display\PathPluginBase->execute() (Line: 196)
Drupal\views\Plugin\views\display\Page->execute() (Line: 1635)
Drupal\views\ViewExecutable->executeDisplay('page_1', Array) (Line: 81)
Drupal\views\Element\View::preRenderViewElement(Array)
call_user_func_array(Array, Array) (Line: 101)
Drupal\Core\Render\Renderer->doTrustedCallback(Array, Array, 'Render #pre_render callbacks must be methods of a class that implements \Drupal\Core\Security\TrustedCallbackInterface or be an anonymous function. The callback was %s. See https://www.drupal.org/node/2966725', 'exception', 'Drupal\Core\Render\Element\RenderCallbackInterface') (Line: 788)
Drupal\Core\Render\Renderer->doCallback('#pre_render', Array, Array) (Line: 374)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 204)
Drupal\Core\Render\Renderer->render(Array, ) (Line: 242)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 580)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 243)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 132)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object)
call_user_func(Array, Object, 'kernel.view', Object) (Line: 142)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object, 'kernel.view') (Line: 174)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 81)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 718)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

cilefen’s picture

Status: Postponed (maintainer needs more info) » Needs review
smustgrave’s picture

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

Was previously tagged for steps to reproduce, see that's missing in the issue summary.

Typically for issues like this we need to discover why it's empty at this location. Putting just a check may be covering a bigger problem.

Regardless will need test coverage.

ahmad khader’s picture

I'm running into a similar problem after upgrading the site from 8 to 9 ,
I'm using grouped filter exposed with 'any' checked, allowing multiple values is disabled and the operation is "is one of".
the value inside $selected_group when broke is

array:1 [▼
  1 => "1"
]
The website encountered an unexpected error. Please try again later.
TypeError: Illegal offset type in isset or empty in Drupal\views\Plugin\views\filter\FilterPluginBase->convertExposedInput() (line 1407 of core/modules/views/src/Plugin/views/filter/FilterPluginBase.php).
Drupal\views\Plugin\views\filter\FilterPluginBase->convertExposedInput(Array, NULL) (Line: 1365)
Drupal\views\ViewExecutable->_build('filter') (Line: 1267)
Drupal\views\ViewExecutable->build(NULL) (Line: 1396)
Drupal\views\ViewExecutable->execute(NULL) (Line: 1459)
Drupal\views\ViewExecutable->render() (Line: 131)
Drupal\views\Plugin\views\display\Block->execute() (Line: 1635)
Drupal\views\ViewExecutable->executeDisplay('professionals_pager', Array) (Line: 81)
Drupal\views\Element\View::preRenderViewElement(Array) (Line: 59)
Drupal\views\Plugin\Block\ViewsBlock->build() (Line: 90)
Drupal\ds\Plugin\DsField\BlockBase->build() (Line: 364)
ds_entity_view_alter(Array, Object, Object) (Line: 562)
Drupal\Core\Extension\ModuleHandler->alter('user_view', Array, Object, Object) (Line: 305)
Drupal\Core\Entity\EntityViewBuilder->buildMultiple(Array) (Line: 239)
Drupal\Core\Entity\EntityViewBuilder->build(Array)
call_user_func_array(Array, Array) (Line: 101)
Drupal\Core\Render\Renderer->doTrustedCallback(Array, Array, 'Render #pre_render callbacks must be methods of a class that implements \Drupal\Core\Security\TrustedCallbackInterface or be an anonymous function. The callback was %s. See https://www.drupal.org/node/2966725', 'exception', 'Drupal\Core\Render\Element\RenderCallbackInterface') (Line: 788)
Drupal\Core\Render\Renderer->doCallback('#pre_render', Array, Array) (Line: 374)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 204)
Drupal\Core\Render\Renderer->render(Array, ) (Line: 242)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 580)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 243)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 132)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object)
call_user_func(Array, Object, 'kernel.view', Object) (Line: 142)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object, 'kernel.view') (Line: 174)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 81)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 718)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
aurora.luzzardi’s picture

Hi,
I was facing that issue, the patch solves it, but it break with the patch for this issue: https://www.drupal.org/project/drupal/issues/3357973
This issue: https://www.drupal.org/project/drupal/issues/3357973 solves both cases, I would say with more testing we can close the issue https://www.drupal.org/project/drupal/issues/3336222

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

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

baluertl’s picture

Issue summary: View changes
cilefen’s picture

Status: Postponed (maintainer needs more info) » Closed (duplicate)

Drupal 9 is no longer supported. There will be no further releases.

Based on comments from last year, this is a duplicate.

jillh68’s picture

StatusFileSize
new777 bytes

Patch that applies to 10.4.x

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

robloach’s picture

Version: 11.x-dev » 11.2.x-dev
Priority: Major » Normal
Status: Closed (duplicate) » Reviewed & tested by the community

The above patch applies cleanly to Drupal 11.2.x, 11.1.x, 11.0.x, 10.*, etc. I've opened up a MR for this over at:
https://git.drupalcode.org/project/drupal/-/merge_requests/12750

smustgrave’s picture

Status: Reviewed & tested by the community » Postponed (maintainer needs more info)

This was marked as a duplicate to check the parent issue

coaston’s picture

Patch #15 worked and message issue disappear from logs but Filter still does not work - it won't show any result. So this patch fixed just "message" it seems.

quietone’s picture

Version: 11.2.x-dev » 11.x-dev
Status: Postponed (maintainer needs more info) » Closed (duplicate)
Issue tags: +Bug Smash Initiative

It isn't clear to me why a duplicate issue was re-opened. As a duplicate, work continues in the other issue, which is #3357973: Grouped exposed filters do not work when input from user is an array.

I am restoring the duplicate status, and other meta data, of this issue and closing the MR.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.