Problem/Motivation
Fix PHP Fatal error resulting in WSOD, occurring when saving AdminToolbarSettingsForm:
Error: Call to undefined method Drupal\Core\Menu\MenuLinkManager::invalidateAll() in Drupal\admin_toolbar\Form\AdminToolbarSettingsForm->submitForm() (line 84 of /var/www/html/web/modules/contrib/admin_toolbar/src/Form/AdminToolbarSettingsForm.php).
Detailed stacktrace :
#0 [internal function]: Drupal\admin_toolbar\Form\AdminToolbarSettingsForm->submitForm(Array, Object(Drupal\Core\Form\FormState))
#1 /var/www/html/web/core/lib/Drupal/Core/Form/FormSubmitter.php(129): call_user_func_array(Array, Array)
#2 /var/www/html/web/core/lib/Drupal/Core/Form/FormSubmitter.php(67): Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object(Drupal\Core\Form\FormState))
#3 /var/www/html/web/core/lib/Drupal/Core/Form/FormBuilder.php(597): Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object(Drupal\Core\Form\FormState))
#4 /var/www/html/web/core/lib/Drupal/Core/Form/FormBuilder.php(326): Drupal\Core\Form\FormBuilder->processForm('admin_toolbar_s...', Array, Object(Drupal\Core\Form\FormState))
#5 /var/www/html/web/core/lib/Drupal/Core/Controller/FormController.php(73): Drupal\Core\Form\FormBuilder->buildForm(Object(Drupal\admin_toolbar\Form\AdminToolbarSettingsForm), Object(Drupal\Core\Form\FormState))
#6 [internal function]: Drupal\Core\Controller\FormController->getContentResult(Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\RouteMatch))
#7 /var/www/html/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array)
#8 /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php(638): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#9 /var/www/html/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#10 /var/www/html/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array)
#11 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(181): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#12 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(76): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#13 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/Session.php(53): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#14 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#15 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/ContentLength.php(28): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#16 /var/www/html/web/core/modules/big_pipe/src/StackMiddleware/ContentLength.php(32): Drupal\Core\StackMiddleware\ContentLength->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#17 /var/www/html/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\big_pipe\StackMiddleware\ContentLength->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#18 /var/www/html/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#19 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#20 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#21 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php(36): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#22 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\Core\StackMiddleware\AjaxPageState->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#23 /var/www/html/web/core/lib/Drupal/Core/DrupalKernel.php(741): Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#24 /var/www/html/web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#25 {main}
Steps to reproduce
0 - Install the admin_toolbar module
1 - Browse to the Admin Toolbar settings at: /admin/config/user-interface/admin-toolbar
under: Home > Administration > Configuration > User interface > Admin Toolbar settings
2 - Save the form by clicking on the Save configuration button.
3 - Confirm the page crashes with WSOD error:
The website encountered an unexpected error. Try again later.
Error: Call to undefined method Drupal\Core\Menu\MenuLinkManager::invalidateAll() in Drupal\admin_toolbar\Form\AdminToolbarSettingsForm->submitForm() (line 107 of modules/contrib/admin_toolbar/src/Form/AdminToolbarSettingsForm.php).
Proposed resolution
This issue seems to have been introduced in commit:
https://git.drupalcode.org/project/admin_toolbar/-/commit/efb450aeb115f7...
It appears the values for $container->get were reversed when injecting the dependencies.
Solution: Set the injected dependencies in the correct order, for each respective property.
Additionally, add a basic automated test class to confirm the changes fix the issue.
Issue fork admin_toolbar-3466125
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
Comment #3
dydave commentedQuick follow-up on this issue:
1 - Added automated tests for the 'AdminToolbarSettingsForm' at:
https://git.drupalcode.org/issue/admin_toolbar-3466125/-/commit/ac51e260...
and ran pipeline to demonstrate the tests would fail:
https://git.drupalcode.org/issue/admin_toolbar-3466125/-/pipelines/245075
2 - Fixed fatal error 'Call to undefined method Drupal\Core\Menu\MenuLinkManager::invalidateAll()' at:
https://git.drupalcode.org/issue/admin_toolbar-3466125/-/commit/ba61d199...
and ran pipeline to demonstrate the changes would fix the issue:
https://git.drupalcode.org/issue/admin_toolbar-3466125/-/pipelines/245084
Added testing for the
Menu depthform setting:✅ The merge request seems to be passing all tests, thus moving issue to Needs review.
We would greatly appreciate if a maintainer or someone with write permission could take a look at ticket's merge request MR!94 and let us know if there would be any more work needed.
Feel free to let us know if you have any questions or concerns on any of the changes in the merge request or any aspect of this ticket in general, we would surely be glad to help.
Thanks in advance for your feedback and reviews.
Comment #4
baluertlThe patch solves the exception when saving the module settings form on D11.0.0 core hence RTBC.
Comment #5
dydave commentedComment #6
neurer commentedCan confirm MR !94 fixes this. Please commit.
Comment #7
teknocat commentedThe same fix also needs to be applied to AdminToolbarToolsSettingsForm.
Comment #10
japerryComment #12
anybodyHi @japerry would it be possible to tag a new release with this fix perhaps? Thanks :)