TypeError: Illegal offset type in Drupal\taxonomy\Form\OverviewTerms->submitForm()

Created on 3 September 2024, 3 months ago
Updated 17 September 2024, 2 months ago

Problem/Motivation

Trying to reorder on `admin/structure/taxonomy/manage/{VOCAB-ID}/overview
TypeError: Illegal offset type in Drupal\taxonomy\Form\OverviewTerms->submitForm() (line 630 of /mnt/www/html/njcourts/docroot/core/modules/taxonomy/src/Form/OverviewTerms.php).

Proposed resolution

Add int check around values before trying to set.

🐛 Bug report
Status

Active

Version

11.0 🔥

Component
Taxonomy 

Last updated about 15 hours ago

  • Maintained by
  • 🇺🇸United States @xjm
  • 🇬🇧United Kingdom @catch
Created by

🇺🇸United States EthanT Sarasota, Florida

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

Comments & Activities

  • Issue created by @EthanT
  • 🇺🇸United States EthanT Sarasota, Florida

    ethant changed the visibility of the branch 3471875-typeerror-illegal-offset to hidden.

  • 🇺🇸United States EthanT Sarasota, Florida
  • Thanks for the report and a patch. What is $raw_term->parents on this site and how do we set this up to reproduce the bug?

  • 🇮🇳India anandhi karnan Chennai

    Hi

    I tried to reproduce the issue (TypeError: Illegal offset type in Drupal\taxonomy\Form\OverviewTerms->submitForm()) in Drupal 11.x but was unable to replicate it. I have attached a screen recording for reference.

    Here are the steps I followed:

    • Navigated to admin/structure/taxonomy.
    • Clicked on “Add vocabulary”.
    • Entered a name for the new vocabulary and saved it.
    • Accessed the newly created vocabulary.
    • Clicked “Add term” to create several terms within this vocabulary.
    • Went to the overview page for the vocabulary at admin/structure/taxonomy/manage/{VOCAB-ID}/overview, where {VOCAB-ID} is the ID of the vocabulary.
    • Tried to reorder the terms by dragging them or using any available UI controls.
    • Saved the changes by clicking the “Save” button.
  • 🇺🇸United States TolstoyDotCom L.A.

    In the existing code, I'm not clear on why it's $raw_term->parents[0] == 0 instead of just !$raw_term->parents[0] or similar. Does $raw_term->parents always exist and is it always an array? If $raw_term->parents[0] is NULL or "", is that equivalent to being 0 or does it always have to be a number? What if it's "0"? For the change, it seems like farming the checks out to other methods or a library would be better. Either of those could check if $raw_term->parents[0] exists and has a number or something else.

Production build 0.71.5 2024