TypeError: in_array(): Argument #2 ($haystack) must be of type array, null given in in_array() in Drupal\user\Form\UserPermissionsForm

Created on 16 May 2023, over 1 year ago
Updated 12 December 2023, 11 months ago

Problem/Motivation

  • We got an Internal Server error with the following error:
    TypeError: in_array(): Argument #2 ($haystack) must be of type array, null given in in_array() (line 198 of /var/www/cloud_orchestrator/docroot/core/modules/user/src/Form/UserPermissionsForm.php)
    #0 /var/www/cloud_orchestrator/docroot/core/modules/user/src/Form/UserPermissionsForm.php(198): in_array('add aws cloud i...', NULL)
    #1 [internal function]: Drupal\user\Form\UserPermissionsForm->buildForm(Array, Object(Drupal\Core\Form\FormState))
    #2 /var/www/cloud_orchestrator/docroot/core/lib/Drupal/Core/Form/FormBuilder.php(536): call_user_func_array(Array, Array)
    #3 /var/www/cloud_orchestrator/docroot/core/lib/Drupal/Core/Form/FormBuilder.php(283): Drupal\Core\Form\FormBuilder->retrieveForm('user_admin_perm...', Object(Drupal\Core\Form\FormState))
    #4 /var/www/cloud_orchestrator/docroot/core/lib/Drupal/Core/Controller/FormController.php(73): Drupal\Core\Form\FormBuilder->buildForm(Object(Drupal\user\Form\UserPermissionsForm), Object(Drupal\Core\Form\FormState))
    #5 [internal function]: Drupal\Core\Controller\FormController->getContentResult(Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\RouteMatch))
    #6 /var/www/cloud_orchestrator/docroot/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array)
    #7 /var/www/cloud_orchestrator/docroot/core/lib/Drupal/Core/Render/Renderer.php(580): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
    #8 /var/www/cloud_orchestrator/docroot/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
    #9 /var/www/cloud_orchestrator/docroot/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array)
    #10 /var/www/cloud_orchestrator/vendor/symfony/http-kernel/HttpKernel.php(169): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
    #11 /var/www/cloud_orchestrator/vendor/symfony/http-kernel/HttpKernel.php(81): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
    #12 /var/www/cloud_orchestrator/docroot/modules/contrib/simple_oauth/src/HttpMiddleware/BasicAuthSwap.php(68): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #13 /var/www/cloud_orchestrator/docroot/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Drupal\simple_oauth\HttpMiddleware\BasicAuthSwap->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #14 /var/www/cloud_orchestrator/docroot/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #15 /var/www/cloud_orchestrator/docroot/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #16 /var/www/cloud_orchestrator/docroot/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #17 /var/www/cloud_orchestrator/docroot/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #18 /var/www/cloud_orchestrator/docroot/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #19 /var/www/cloud_orchestrator/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #20 /var/www/cloud_orchestrator/docroot/core/lib/Drupal/Core/DrupalKernel.php(718): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #21 /var/www/cloud_orchestrator/docroot/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
    #22 {main}

Steps to reproduce

  • For example, when we set up permissions: NULL in user.role.authenticated.yml, then the error occurs.

Proposed resolution

Add the validation at https://git.drupalcode.org/project/drupal/-/blob/10.1.x/core/modules/use...

🐛 Bug report
Status

Needs work

Version

11.0 🔥

Component
User system 

Last updated 2 days ago

Created by

🇺🇸United States yas California 🇺🇸

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

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

Production build 0.71.5 2024