Problem/Motivation

After updating to Drupal 11.3 from 11.2.10, ALL Taxonomy overview pages are broken on my site.

I understand from digging deeper that this my be due to....

...in 11.3.x, Drupal changed when and how the overview form object is constructed, and $this->entity is now NULL at alter time for that form.

After injecting a bit of debug code into core/lib/Drupal/Core/Entity/EntityForm.php, I think I may have uncovered Simple Site Map as a possible culprit...

TypeError: Drupal\simple_sitemap\Form\FormHelper::resolveEntityFormHandler(): Argument #1 ($entity) must be of type Drupal\Core\Entity\EntityInterface, null given, called in C:\laragon\www\bit-by-bit.org\public_html\modules\contrib\simple_sitemap\src\Form\FormHelper.php on line 125 in Drupal\simple_sitemap\Form\FormHelper->resolveEntityFormHandler() (line 157 of modules\contrib\simple_sitemap\src\Form\FormHelper.php).

Rolling back to Drupal 11.2.10 and the problem disappears so I'm reasonably confident in my analysis of the root cause of the issue being the 'breaking' Drupal core change.

Comments

sirclickalot created an issue.

gbyte’s picture

With 'overview page' do you mean the taxonomy list or the taxonomy entity form?

I have just updated to 11.3 on my test instance, turned on all simple_sitemap modules, configured the module to index taxonomy terms of type 'tags' and have no such issues.

No problem on either /admin/structure/taxonomy/manage/tags/overview nor /taxonomy/term/40/edit.

Can you please install the latest dev, uninstall all custom & 3rd party modules that hook into simple_sitemap and if you encounter the issue provide the full stack trace so we know there the issue starts?

sirclickalot’s picture

Notes

Thank you for your response.

In answer to your first question, I am seeing this on any Taxonomy overview page, i.e. the page that
lists the terms, prior to one attempting to edit any.

As an extra piece of of information that may help, I am actually NOT including a Taxonomy terms' URLs in my Sitemap,
only node URLs.

I have no other modules that attempt to hook into anything in:
modules/contrib/simple_sitemap/simple_sitemap.api.php

Initial reasoning for waggling a finger at Simple Site Map

With Drupal 11.3.0 onwards, the following code from core/lib/Drupal/Core/Entity/EntityForm.php ...

public function getBaseFormId() {
   $base_form_id = $this->entity->getEntityTypeId() . '_form';
   if ($base_form_id == $this->getFormId()) {
     $base_form_id = NULL;
   }
   return $base_form_id;
 }

... throws an exception if $this->entity is null.

In the Drupal <11.3 version of our site, visiting:
/admin/structure/taxonomy/manage/level/overview

Shows the terms listed in the 'level' taxonomy as expected.

In the Drupal 11.3 version of our site, visiting: /admin/structure/taxonomy/manage/level/overview

Triggers the following fatal error ...

Error: Call to a member function getEntityTypeId() on null in Drupal\Core\Entity\EntityForm->getBaseFormId() (line 70 of core/lib/Drupal/Core/Entity/EntityForm.php).
Drupal\Core\Form\FormBuilder->getFormId(Object, Object) (Line: 251)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 73)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 634)
Drupal\Core\Render\Renderer::Drupal\Core\Render\{closure}()
Fiber->start() (Line: 635)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 121)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 183)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 53)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 28)
Drupal\Core\StackMiddleware\ContentLength->handle(Object, 1, 1) (Line: 32)
Drupal\big_pipe\StackMiddleware\ContentLength->handle(Object, 1, 1) (Line: 118)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 92)
Drupal\page_cache\StackMiddleware\PageCache->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: 53)
Drupal\Core\StackMiddleware\AjaxPageState->handle(Object, 1, 1) (Line: 54)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 745)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

public function getBaseFormId() {
   if (!$this->entity) {
     return NULL;
   }
   $base_form_id ...
 

Further reveals where the null may have come from? ...

TypeError: Drupal\simple_sitemap\Form\FormHelper::resolveEntityFormHandler(): Argument #1 ($entity) must be of type Drupal\Core\Entity\EntityInterface, null given, called in .../modules/contrib/simple_sitemap/src/Form/FormHelper.php on line 125 in Drupal\simple_sitemap\Form\FormHelper->resolveEntityFormHandler() (line 157 of modules/contrib/simple_sitemap/src/Form/FormHelper.php).
Drupal\simple_sitemap\Form\FormHelper->formAlter(Array, Object) (Line: 44)
simple_sitemap_form_alter(Array, Object, 'taxonomy_overview_terms') (Line: 460)
Drupal\Core\Extension\ModuleHandler->alter(Array, Array, Object, 'taxonomy_overview_terms') (Line: 892)
Drupal\Core\Form\FormBuilder->prepareForm('taxonomy_overview_terms', Array, Object) (Line: 304)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 73)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 634)
Drupal\Core\Render\Renderer::Drupal\Core\Render\{closure}()
Fiber->resume() (Line: 649)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 121)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 183)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 53)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 28)
Drupal\Core\StackMiddleware\ContentLength->handle(Object, 1, 1) (Line: 32)
Drupal\big_pipe\StackMiddleware\ContentLength->handle(Object, 1, 1) (Line: 118)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 92)
Drupal\page_cache\StackMiddleware\PageCache->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: 53)
Drupal\Core\StackMiddleware\AjaxPageState->handle(Object, 1, 1) (Line: 54)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 745)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Justification for NOT waggling a finger at Simple Site Map

HOWEVER, uninstalling the Simple XML Sitemap module reveals another named module (Simplify) showing
up as the source of the 'offending' form_alter ...

...
TypeError: class_implements(): Argument #1 ($object_or_class) must be of type object|string, null given in class_implements() (line 369 of modules/contrib/simplify/simplify.module).
simplify_form_alter(Array, Object, 'taxonomy_overview_terms') (Line: 460)
Drupal\Core\Extension\ModuleHandler->alter(Array, Array, Object, 'taxonomy_overview_terms') (Line: 892)
...

HOWEVER, uninstalling the Simplify module reveals another named module (Front End Editing) showing
up as the source of the 'offending' form_alter ...

...
Error: Call to a member function getEntityTypeId() on null in Drupal\frontend_editing\Hook\FormAlter->formAlter() (line 75 of modules/contrib/frontend_editing/src/Hook/FormAlter.php).
...

Conclusions

I'm pretty sure my debugging above is rubbish! - I think that all I am doing here here is 'passing on' the
null ID to the next module in turn and clearly the finger-waggling at Simple XLM Sitemap was unjustified.

Simple XLM Sitemap is not the culprit, and we could just close this issue but I should like to keep it open
and/or take some advice from anyone as to how to ascertain what one earth is causing all this upset since the update
to Drupal 11.3.

Might 'something' much further back in the page rendering process be causing this and if so, how to best debug?

I do have a pretty vast amount of modules active on the site ;-(

Thanks all!