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.

Issue fork drupal-3471875

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

ethant created an issue. See original summary.

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

ethant’s picture

StatusFileSize
new781 bytes
cilefen’s picture

Version: 10.2.x-dev » 11.x-dev
Issue tags: +Needs steps to reproduce, +Needs merge request

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?

anandhi karnan’s picture

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.
tolstoydotcom’s picture

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.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.