Fatal error is triggered

When accessing the Metatag defaults administration page, a fatal error is triggered preventing the page from rendering. This is on updating to version 2.2.3 on Drupal 11.4.11.

Steps to reproduce

Navigate to the Metatag configurations/defaults page /admin/config/search/metatag). Error is: Call to a member function addMessage() on null in Drupal\metatag\MetatagDefaultsListBuilder->render() (line 204 of /var/www/html/web/modules/contrib/metatag/src/MetatagDefaultsListBuilder.php).

Issue fork metatag-3633665

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

hcksharp created an issue. See original summary.

hcksharp’s picture

Issue summary: View changes
hcksharp’s picture

Component: User interface » Code

wkr1shna made their first commit to this issue’s fork.

wkr1shna’s picture

Assigned: Unassigned » wkr1shna

wkr1shna’s picture

Status: Active » Needs review
damienmckenna’s picture

Assigned: wkr1shna » Unassigned
damienmckenna’s picture

I'm not able to reproduce this. Did you rebuild the caches after updating to 2.2.3? I'll be releasing 2.2.4 shortly.

hcksharp’s picture

@damienmckenna if I take the site out of maintenance mode I can access the admin/config/search/metatag. In maintenance mode it crashes the metatag admin page with the fatal error.

If I update the line 204 from "$this->messenger->addMessage to $this->messenger()->addMessage metatag admin page works in and out of maintenance. Looked at a previous version 2.2.0 and see that the line was changed in the newer one.

Stack trace:

#0 /var/www/html/web/core/lib/Drupal/Core/Entity/Controller/EntityListController.php(23): Drupal\metatag\MetatagDefaultsListBuilder->render()
#1 [internal function]: Drupal\Core\Entity\Controller\EntityListController->listing()
#2 /var/www/html/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array()
#3 /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php(638): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->{closure:Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber::wrapControllerExecutionInRenderContext():121}()
#4 [internal function]: Drupal\Core\Render\Renderer::{closure:Drupal\Core\Render\Renderer::executeInRenderContext():638}()
#5 /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php(639): Fiber->start()
#6 /var/www/html/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(121): Drupal\Core\Render\Renderer->executeInRenderContext()
#7 /var/www/html/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext()
#8 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(185): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->{closure:Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber::onController():96}()
#9 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(76): Symfony\Component\HttpKernel\HttpKernel->handleRaw()
#10 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/Session.php(53): Symfony\Component\HttpKernel\HttpKernel->handle()
#11 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(30): Drupal\Core\StackMiddleware\Session->handle()
#12 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/ContentLength.php(28): Drupal\Core\StackMiddleware\KernelPreHandle->handle()
#13 /var/www/html/web/core/modules/big_pipe/src/StackMiddleware/ContentLength.php(32): Drupal\Core\StackMiddleware\ContentLength->handle()
#14 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\big_pipe\StackMiddleware\ContentLength->handle()
#15 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle()
#16 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php(71): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle()
#17 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(54): Drupal\Core\StackMiddleware\AjaxPageState->handle()
#18 /var/www/html/web/core/lib/Drupal/Core/DrupalKernel.php(753): Drupal\Core\StackMiddleware\StackedHttpKernel->handle()
#19 /var/www/html/vendor/symfony/runtime/Runner/Symfony/HttpKernelRunner.php(34): Drupal\Core\DrupalKernel->handle()
#20 /var/www/html/vendor/autoload_runtime.php(32): Symfony\Component\Runtime\Runner\Symfony\HttpKernelRunner->run()
#21 /var/www/html/web/autoload_runtime.php(22): require('...')
#22 /var/www/html/web/index.php(13): require_once('...')
#23 {main}
camhoward’s picture

I'm having the same issue on both Drupal 10.6.20 and 11.4.11 after updating to Metatag 2.2.4 and rebuilding caches.

When the sites are in Maintenance mode, going to /admin/config/search/metatag results in a WSOD with the message: "The website encountered an unexpected error. Try again later."

The Drupal error log reports the same "Call to a member function addMessage()..." error reported by @hcksharp in the issue summary.

When the sites are not in Maintenance mode, going to /admin/config/search/metatag works fine.

damienmckenna changed the visibility of the branch 2.2.x to hidden.

damienmckenna’s picture

Status: Needs review » Reviewed & tested by the community
Parent issue: » #3634032: Plan for Metatag 2.2.5

I've confirmed the bug and confirmed the fix - thank you. This will be included in the upcoming 2.2.5 release.

damienmckenna’s picture

Status: Reviewed & tested by the community » Fixed

Committed. Thank you.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.