TypeError: in_array(): Argument #2 ($haystack) must be of type array, null given in ModuleRequiredByThemesUninstallValidator.php on line 99

Created on 24 March 2023, about 2 years ago
Updated 20 November 2023, over 1 year ago

Problem/Motivation

TypeError: in_array(): Argument #2 ($haystack) must be of type array, null given in core/lib/Drupal/Core/Extension/ModuleRequiredByThemesUninstallValidator.php on line 99

Steps to reproduce

Click on Modules - Uninstall

Proposed resolution

Replace line 99 of ModuleRequiredByThemesUninstallValidator.php:

if (in_array($module, $theme['dependencies'])) {
to:
if (in_array($module, $theme['dependencies'] ?? [])) {

🐛 Bug report
Status

Closed: works as designed

Version

9.5

Component
Base 

Last updated about 2 hours ago

Created by

🇮🇩Indonesia drupalnesia

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

Comments & Activities

  • Issue created by @drupalnesia
  • Status changed to Active about 2 years ago
  • Thanks for reporting a core bug.

    We have seen a lot of bug reports like this suggesting defensive coding solutions, but in many cases the real problem is wrong API implementations by contributed or custom code.

    Can you please get a stack trace and determine the project that is passing the bad value?

    Thank you!

  • Status changed to Postponed: needs info about 2 years ago
  • I am postponing pending steps to reproduce. Viewing the Uninstall UI is a common activity that has test coverage so I don't think this bug is experienced widely.

  • 🇮🇩Indonesia drupalnesia

    Hard to reproduce this error, any idea?

    Below is the complete error log when I visit Module-Uninstall:

    [26-Mar-2023 19:32:41 Asia/Jakarta] TypeError: in_array(): Argument #2 ($haystack) must be of type array, null given in /home/dempodru0835/public_html/core/lib/Drupal/Core/Extension/ModuleRequiredByThemesUninstallValidator.php on line 99 #0 /home/dempodru0835/public_html/core/lib/Drupal/Core/Extension/ModuleRequiredByThemesUninstallValidator.php(99): in_array()
    #1 [internal function]: Drupal\Core\Extension\ModuleRequiredByThemesUninstallValidator->Drupal\Core\Extension\{closure}()
    #2 /home/dempodru0835/public_html/core/lib/Drupal/Core/Extension/ModuleRequiredByThemesUninstallValidator.php(98): array_map()
    #3 /home/dempodru0835/public_html/core/lib/Drupal/Core/Extension/ModuleRequiredByThemesUninstallValidator.php(52): Drupal\Core\Extension\ModuleRequiredByThemesUninstallValidator->getThemesDependingOnModule()
    #4 /home/dempodru0835/public_html/core/lib/Drupal/Core/Extension/ModuleInstaller.php(624): Drupal\Core\Extension\ModuleRequiredByThemesUninstallValidator->validate()
    #5 /home/dempodru0835/public_html/core/lib/Drupal/Core/ProxyClass/Extension/ModuleInstaller.php(99): Drupal\Core\Extension\ModuleInstaller->validateUninstall()
    #6 /home/dempodru0835/public_html/core/modules/system/src/Form/ModulesUninstallForm.php(165): Drupal\Core\ProxyClass\Extension\ModuleInstaller->validateUninstall()
    #7 [internal function]: Drupal\system\Form\ModulesUninstallForm->buildForm()
    #8 /home/dempodru0835/public_html/core/lib/Drupal/Core/Form/FormBuilder.php(534): call_user_func_array()
    #9 /home/dempodru0835/public_html/core/lib/Drupal/Core/Form/FormBuilder.php(281): Drupal\Core\Form\FormBuilder->retrieveForm()
    #10 /home/dempodru0835/public_html/core/lib/Drupal/Core/Controller/FormController.php(73): Drupal\Core\Form\FormBuilder->buildForm()
    #11 [internal function]: Drupal\Core\Controller\FormController->getContentResult()
    #12 /home/dempodru0835/public_html/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array()
    #13 /home/dempodru0835/public_html/core/lib/Drupal/Core/Render/Renderer.php(580): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
    #14 /home/dempodru0835/public_html/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext()
    #15 /home/dempodru0835/public_html/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext()
    #16 /home/dempodru0835/public_html/vendor/symfony/http-kernel/HttpKernel.php(169): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
    #17 /home/dempodru0835/public_html/vendor/symfony/http-kernel/HttpKernel.php(81): Symfony\Component\HttpKernel\HttpKernel->handleRaw()
    #18 /home/dempodru0835/public_html/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle()
    #19 /home/dempodru0835/public_html/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle()
    #20 /home/dempodru0835/public_html/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle()
    #21 /home/dempodru0835/public_html/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass()
    #22 /home/dempodru0835/public_html/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle()
    #23 /home/dempodru0835/public_html/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle()
    #24 /home/dempodru0835/public_html/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle()
    #25 /home/dempodru0835/public_html/core/lib/Drupal/Core/DrupalKernel.php(718): Stack\StackedHttpKernel->handle()
    #26 /home/dempodru0835/public_html/index.php(19): Drupal\Core\DrupalKernel->handle()
    #27 {main}
    
  • Status changed to Closed: works as designed about 2 years ago
  • 🇮🇩Indonesia drupalnesia

    Fixed.

    I found my .info.yml file contains "dependencies" but the folder deleted.
    Just upload the dependency manually then works fine!

    Takes hours .. because Drupal does not report the module name. I suggest Drupal stop the process after ONE error occured, maybe a variable in settings.php for debugging.

  • 🇺🇸United States caspervoogt

    In my case what solved it was that my custom theme's info.yml contained a core/once dependency, while my themes's libraries.yml already contained that dependency. I removed the dependencies code block from my info.yml and that fixed it.

Production build 0.71.5 2024