Undefined index in Drupal\taxonomy\Form\OverviewTerms->buildForm()

Created on 21 March 2022, over 2 years ago
Updated 18 June 2024, 5 months ago

Problem/Motivation

I encountered a rare issue when tried to sort manually some terms of taxonomy in the overview page and it won't save.

Steps to reproduce

  • Using drupal 9.3.8
  • Having a large number of terms in a taxonomy vocabulary (between 300 to 400 terms)
  • Configure the number of terms per page to 500 drush cset taxonomy.settings terms_per_page_admin 500
  • Go to /admin/structure/taxonomy/manage/produit_nuancier/overview
  • Manually move some terms, then save

It won't save anything. But we can find in the report this message for each term of the vocabulary :

Notice : Undefined index: tid:594:0 dans Drupal\taxonomy\Form\OverviewTerms->buildForm() (/opt/sites/mysite.com/website/web/core/modules/taxonomy/src/Form/OverviewTerms.php ligne 241)
#0 /opt/sites/mysite.com/website/web/core/includes/bootstrap.inc(346): _drupal_error_handler_real()
#1 /opt/sites/mysite.com/website/web/core/modules/taxonomy/src/Form/OverviewTerms.php(241): _drupal_error_handler()
#2 [internal function]: Drupal\taxonomy\Form\OverviewTerms->buildForm()
#3 /opt/sites/mysite.com/website/web/core/lib/Drupal/Core/Form/FormBuilder.php(531): call_user_func_array()
#4 /opt/sites/mysite.com/website/web/core/lib/Drupal/Core/Form/FormBuilder.php(278): Drupal\Core\Form\FormBuilder->retrieveForm()
#5 /opt/sites/mysite.com/website/web/core/lib/Drupal/Core/Controller/FormController.php(73): Drupal\Core\Form\FormBuilder->buildForm()
#6 [internal function]: Drupal\Core\Controller\FormController->getContentResult()
#7 /opt/sites/mysite.com/website/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array()
#8 /opt/sites/mysite.com/website/web/core/lib/Drupal/Core/Render/Renderer.php(564): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#9 /opt/sites/mysite.com/website/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext()
#10 /opt/sites/mysite.com/website/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext()
#11 /opt/sites/mysite.com/website/vendor/symfony/http-kernel/HttpKernel.php(158): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#12 /opt/sites/mysite.com/website/vendor/symfony/http-kernel/HttpKernel.php(80): Symfony\Component\HttpKernel\HttpKernel->handleRaw()
#13 /opt/sites/mysite.com/website/web/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle()
#14 /opt/sites/mysite.com/website/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle()
#15 /opt/sites/mysite.com/website/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle()
#16 /opt/sites/mysite.com/website/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass()
#17 /opt/sites/mysite.com/website/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle()
#18 /opt/sites/mysite.com/website/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle()
#19 /opt/sites/mysite.com/website/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle()
#20 /opt/sites/mysite.com/website/web/core/lib/Drupal/Core/DrupalKernel.php(708): Stack\StackedHttpKernel->handle()
#21 /opt/sites/mysite.com/website/web/index.php(19): Drupal\Core\DrupalKernel->handle()
#22 {main}

Proposed resolution

I resolved my problem by showing less term per page (200) in order to have a pager
drush cset taxonomy.settings terms_per_page_admin 200

πŸ› Bug report
Status

Closed: cannot reproduce

Version

9.5

Component
TaxonomyΒ  β†’

Last updated 5 days ago

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

πŸ‡«πŸ‡·France thomas-at-passerelle

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡³πŸ‡ΏNew Zealand quietone

    @thomas-at-passerelle, Thank you for reporting this problem. We rely on issue reports like this to improve Drupal core.

    I tested this on Drupal 10.1.x, standard install in Italian. I used devel_generate to make 1000 terms in the Tags vocabulary. I followed the steps in the issues summary and like @yovanny.gomez.oyola I was not able to reproduce this problem

    Therefore, closing as cannot reproduce. If you are experiencing this problem on a supported version of Drupal reopen the issue, by setting the status to 'Active', and provide complete steps to reproduce the issue β†’ (starting from "Install Drupal core").

    Thanks!

  • πŸ‡¦πŸ‡·Argentina sharif.elshobkshy

    Hi.

    I'm seeing the same bug on one of the testing environments. This indeed seems to be related to big taxonomy trees.
    Additionally, other tickets exist to discuss/address this.

    - https://www.drupal.org/project/drupal/issues/2786793 πŸ› Notice: Undefined index: depth in Drupal\taxonomy\Form\OverviewTerms Closed: outdated
    - https://www.drupal.org/project/drupal/issues/763380 πŸ“Œ Do not use \Drupal\taxonomy\TermStorageInterface::loadTree() in \Drupal\taxonomy\Form\OverviewTerms::buildForm() Postponed
    - https://www.drupal.org/project/drupal/issues/3367182 πŸ› Undefined array key "depth" Active

    This is definitely an ongoing bug.

    Thanks.

  • πŸ‡ΊπŸ‡ΈUnited States troybthompson

    I'm having the same issue. I tried reducing the number of terms per page but it doesn't seem to have an effect. I believe it's because I have a hierarchy and it tries to show all terms per parent on the same page?

    I also get an error about the depth key:
    Warning: Undefined array key "depth" in Drupal\taxonomy\Form\OverviewTerms->buildForm() (line 254 of /usr/www/users/.../web/core/modules/taxonomy/src/Form/OverviewTerms.php)

    This taxonomy was imported from a Drupal 7 site, maybe something didn't get converted correctly? I also have multiple languages. I've edited ones that cause an error and re-saved and that doesn't change things.

    Not all terms on the page get an error entry, it seems like just the ones after the first 250 if that number means something.

    Hopefully this is helpful?

Production build 0.71.5 2024