- Issue created by @EthanT
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]
isNULL
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.