TypeError: Illegal offset type in isset or empty

Created on 24 January 2023, over 2 years ago

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 fixed by apply changes in modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php file

-    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 create 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

πŸ› Bug report
Status

Active

Version

9.5

Component
TaxonomyΒ  β†’

Last updated 19 days ago

  • Maintained by
  • πŸ‡ΊπŸ‡ΈUnited States @xjm
  • πŸ‡¬πŸ‡§United Kingdom @catch
Created by

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

Comments & Activities

  • Issue created by @pankaj1390
  • Status changed to Postponed: needs info over 2 years ago
  • Thanks for the report. We require the steps to reproduce for bugs to understand if there is missing test coverage.

    • Why specifically is $input not a string in this case?
    • Can we get a stack trace too please?
  • 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

  • πŸ‡¨πŸ‡¦Canada smulvih2 Canada 🍁

    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)

  • Status changed to Needs review almost 2 years ago
  • Status changed to Postponed: needs info almost 2 years ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    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.

  • πŸ‡―πŸ‡΄Jordan Ahmad Khader

    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 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)

  • πŸ‡§πŸ‡·Brazil aluzzardi Pelotas, RS

    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 πŸ› Grouped exposed taxonomy term filters does not work when input from user is an array. Needs work
    This issue: https://www.drupal.org/project/drupal/issues/3357973 πŸ› Grouped exposed taxonomy term filters does not work when input from user is an array. Needs work solves both cases, I would say with more testing we can close this issue.

  • πŸ‡­πŸ‡ΊHungary Balu Ertl Budapest πŸ‡ͺπŸ‡Ί
  • Drupal 9 is no longer supported. There will be no further releases.

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

Production build 0.71.5 2024