Pass only strings to UserSession::hasPermission()

Created on 16 December 2023, about 1 year ago
Updated 13 March 2024, 9 months ago

Once I upgraded a site to 10.2, I starte3d getting an error I have tracked down to this module.

This happens:

TypeError: Drupal\Core\Session\PermissionChecker::hasPermission(): Argument #1 ($permission) must be of type string, null given, called in /var/www/html/beta.weavercafe/web/core/lib/Drupal/Core/Session/UserSession.php on line 123 in Drupal\Core\Session\PermissionChecker->hasPermission() (line 23 of /var/www/html/beta.weavercafe/web/core/lib/Drupal/Core/Session/PermissionChecker.php).

Once I uninstalled form_mode_control it stopped.

Backtrace:

#0 /var/www/html/beta.weavercafe/web/core/lib/Drupal/Core/Session/UserSession.php(123): Drupal\Core\Session\PermissionChecker->hasPermission()
#1 /var/www/html/beta.weavercafe/web/core/lib/Drupal/Core/Session/AccountProxy.php(121): Drupal\Core\Session\UserSession->hasPermission()
#2 /var/www/html/beta.weavercafe/web/modules/contrib/form_mode_control/form_mode_control.module(212): Drupal\Core\Session\AccountProxy->hasPermission()
#3 /var/www/html/beta.weavercafe/web/modules/contrib/form_mode_control/form_mode_control.module(40): form_mode_control_control_access_form_mode()
#4 /var/www/html/beta.weavercafe/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(545): form_mode_control_entity_form_display_alter()
#5 /var/www/html/beta.weavercafe/web/core/lib/Drupal/Core/Entity/Entity/EntityFormDisplay.php(133): Drupal\Core\Extension\ModuleHandler->alter()
#6 /var/www/html/beta.weavercafe/web/core/lib/Drupal/Core/Entity/ContentEntityForm.php(284): Drupal\Core\Entity\Entity\EntityFormDisplay::collectRenderDisplay()
#7 /var/www/html/beta.weavercafe/web/core/lib/Drupal/Core/Entity/EntityForm.php(97): Drupal\Core\Entity\ContentEntityForm->init()
#8 [internal function]: Drupal\Core\Entity\EntityForm->buildForm()
#9 /var/www/html/beta.weavercafe/web/core/lib/Drupal/Core/Form/FormBuilder.php(536): call_user_func_array()
#10 /var/www/html/beta.weavercafe/web/core/lib/Drupal/Core/Form/FormBuilder.php(283): Drupal\Core\Form\FormBuilder->retrieveForm()
#11 /var/www/html/beta.weavercafe/web/core/lib/Drupal/Core/Controller/FormController.php(73): Drupal\Core\Form\FormBuilder->buildForm()
#12 [internal function]: Drupal\Core\Controller\FormController->getContentResult()
#13 /var/www/html/beta.weavercafe/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array()
#14 /var/www/html/beta.weavercafe/web/core/lib/Drupal/Core/Render/Renderer.php(627): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#15 /var/www/html/beta.weavercafe/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext()
#16 /var/www/html/beta.weavercafe/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext()
#17 /var/www/html/beta.weavercafe/vendor/symfony/http-kernel/HttpKernel.php(181): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#18 /var/www/html/beta.weavercafe/vendor/symfony/http-kernel/HttpKernel.php(76): Symfony\Component\HttpKernel\HttpKernel->handleRaw()
#19 /var/www/html/beta.weavercafe/web/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle()
#20 /var/www/html/beta.weavercafe/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle()
#21 /var/www/html/beta.weavercafe/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle()
#22 /var/www/html/beta.weavercafe/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass()
#23 /var/www/html/beta.weavercafe/web/modules/contrib/shield/src/ShieldMiddleware.php(270): Drupal\page_cache\StackMiddleware\PageCache->handle()
#24 /var/www/html/beta.weavercafe/web/modules/contrib/shield/src/ShieldMiddleware.php(226): Drupal\shield\ShieldMiddleware->bypass()
#25 /var/www/html/beta.weavercafe/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\shield\ShieldMiddleware->handle()
#26 /var/www/html/beta.weavercafe/web/modules/contrib/cloudflare/src/CloudFlareMiddleware.php(136): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle()
#27 /var/www/html/beta.weavercafe/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\cloudflare\CloudFlareMiddleware->handle()
#28 /var/www/html/beta.weavercafe/web/core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php(36): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle()
#29 /var/www/html/beta.weavercafe/web/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\Core\StackMiddleware\AjaxPageState->handle()
#30 /var/www/html/beta.weavercafe/web/core/lib/Drupal/Core/DrupalKernel.php(704): Drupal\Core\StackMiddleware\StackedHttpKernel->handle()
#31 /var/www/html/beta.weavercafe/web/index.php(19): Drupal\Core\DrupalKernel->handle()
#32 {main}
πŸ› Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States duckydan

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

Comments & Activities

Production build 0.71.5 2024