In_array(): Argument #2 ($haystack) must be of type array, null given in in_array()

Created on 28 June 2023, 12 months ago
Updated 18 July 2023, 12 months ago

We are getting below error. while we are trying upgrade module to latest version

TypeError: in_array(): Argument #2 ($haystack) must be of type array, null given in in_array() (line 41 of /tmp/site/app/modules/contrib/rabbit_hole/src/BehaviorSettingsManager.php)

🐛 Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

🇮🇳India Avinash_patil

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

Comments & Activities

  • Issue created by @Avinash_patil
  • 🇺🇦Ukraine Matroskeen 🇺🇦 Ukraine, Lutsk

    Hi @Avinash_patil! Thanks for the report. Is it reproducible after running the database updates? (drush updb -y)

  • 🇮🇳India Avinash_patil

    Created patch for this issue.

  • Issue was unassigned.
  • Status changed to Needs review 12 months ago
  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 8.0 & MySQL 5.7
    last update 12 months ago
    20 pass
  • Status changed to Needs work 12 months ago
  • 🇺🇦Ukraine Matroskeen 🇺🇦 Ukraine, Lutsk

    Please see my comment #2 and provide some steps to reproduce.

    We also have a test for the upgrade path, so if the issue exists, the test should fail.

  • 🇵🇪Peru hchang

    Hi I'm having the same issue, updb fails with the following error and the patch didn't work for me.

    >  [error]  TypeError: in_array(): Argument #2 ($haystack) must be of type array, null given in in_array() (line 41 of /app/web/modules/contrib/rabbit_hole/src/BehaviorSettingsManager.php) #0 /app/web/modules/contrib/rabbit_hole/src/BehaviorSettingsManager.php(41): in_array('entity_subqueue', NULL, true)
    > #1 /app/web/modules/contrib/rabbit_hole/src/RabbitHolePermissionGenerator.php(59): Drupal\rabbit_hole\BehaviorSettingsManager->entityTypeIsEnabled('entity_subqueue')
    > #2 [internal function]: Drupal\rabbit_hole\RabbitHolePermissionGenerator->permissions()
    > #3 /app/web/core/modules/user/src/PermissionHandler.php(153): call_user_func(Array)
    > #4 /app/web/core/modules/user/src/PermissionHandler.php(112): Drupal\user\PermissionHandler->buildPermissionsYaml()
    > #5 /app/web/core/modules/user/src/Entity/Role.php(202): Drupal\user\PermissionHandler->getPermissions()
    > #6 /app/web/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php(319): Drupal\user\Entity\Role->calculateDependencies()
    > #7 /app/web/core/modules/user/src/Entity/Role.php(179): Drupal\Core\Config\Entity\ConfigEntityBase->preSave(Object(Drupal\user\RoleStorage))
    > #8 /app/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php(562): Drupal\user\Entity\Role->preSave(Object(Drupal\user\RoleStorage))
    > #9 /app/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php(517): Drupal\Core\Entity\EntityStorageBase->doPreSave(Object(Drupal\user\Entity\Role))
    > #10 /app/web/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php(253): Drupal\Core\Entity\EntityStorageBase->save(Object(Drupal\user\Entity\Role))
    > #11 /app/web/core/lib/Drupal/Core/Entity/EntityBase.php(339): Drupal\Core\Config\Entity\ConfigEntityStorage->save(Object(Drupal\user\Entity\Role))
    > #12 /app/web/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php(607): Drupal\Core\Entity\EntityBase->save()
    > #13 /app/web/core/modules/update/update.post_update.php(14): Drupal\Core\Config\Entity\ConfigEntityBase->save()
    > #14 /app/vendor/drush/drush/src/Commands/core/UpdateDBCommands.php(321): update_post_update_add_view_update_notifications_permission(Array)
    > #15 /app/vendor/drush/drush/includes/batch.inc(256): Drush\Commands\core\UpdateDBCommands::updateDoOnePostUpdate('update_post_upd...', Object(DrushBatchContext))
    > #16 /app/vendor/drush/drush/includes/batch.inc(201): _drush_batch_worker()
    > #17 /app/vendor/drush/drush/includes/batch.inc(100): _drush_batch_command('109')
    > #18 /app/vendor/drush/drush/src/Commands/core/UpdateDBCommands.php(175): drush_batch_command('109')
    > #19 [internal function]: Drush\Commands\core\UpdateDBCommands->process('109', Array)
    > #20 /app/vendor/consolidation/annotated-command/src/CommandProcessor.php(257): call_user_func_array(Array, Array)
    > #21 /app/vendor/consolidation/annotated-command/src/CommandProcessor.php(212): Consolidation\AnnotatedCommand\CommandProcessor->runCommandCallback(Array, Object(Consolidation\AnnotatedCommand\CommandData))
    > #22 /app/vendor/consolidation/annotated-command/src/CommandProcessor.php(176): Consolidation\AnnotatedCommand\CommandProcessor->validateRunAndAlter(Array, Array, Object(Consolidation\AnnotatedCommand\CommandData))
    > #23 /app/vendor/consolidation/annotated-command/src/AnnotatedCommand.php(350): Consolidation\AnnotatedCommand\CommandProcessor->process(Object(Symfony\Component\Console\Output\ConsoleOutput), Array, Array, Object(Consolidation\AnnotatedCommand\CommandData))
    > #24 /app/vendor/symfony/console/Command/Command.php(255): Consolidation\AnnotatedCommand\AnnotatedCommand->execute(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
    > #25 /app/vendor/symfony/console/Application.php(1027): Symfony\Component\Console\Command\Command->run(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
    > #26 /app/vendor/symfony/console/Application.php(273): Symfony\Component\Console\Application->doRunCommand(Object(Consolidation\AnnotatedCommand\AnnotatedCommand), Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
    > #27 /app/vendor/symfony/console/Application.php(149): Symfony\Component\Console\Application->doRun(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
    > #28 /app/vendor/drush/drush/src/Runtime/Runtime.php(118): Symfony\Component\Console\Application->run(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
    > #29 /app/vendor/drush/drush/src/Runtime/Runtime.php(48): Drush\Runtime\Runtime->doRun(Array, Object(Symfony\Component\Console\Output\ConsoleOutput))
    > #30 /app/vendor/drush/drush/drush.php(72): Drush\Runtime\Runtime->run(Array)
    > #31 /app/vendor/drush/drush/drush(4): require('/app/vendor/dru...')
    > #32 /app/vendor/bin/drush(117): include('/app/vendor/dru...')
    > #33 {main}.
    > TypeError: in_array(): Argument #2 ($haystack) must be of type array, null given in /app/web/modules/contrib/rabbit_hole/src/BehaviorSettingsManager.php on line 41 #0 /app/web/modules/contrib/rabbit_hole/src/BehaviorSettingsManager.php(41): in_array('entity_subqueue', NULL, true)
    > #1 /app/web/modules/contrib/rabbit_hole/src/RabbitHolePermissionGenerator.php(59): Drupal\rabbit_hole\BehaviorSettingsManager->entityTypeIsEnabled('entity_subqueue')
    > #2 [internal function]: Drupal\rabbit_hole\RabbitHolePermissionGenerator->permissions()
    > #3 /app/web/core/modules/user/src/PermissionHandler.php(153): call_user_func(Array)
    > #4 /app/web/core/modules/user/src/PermissionHandler.php(112): Drupal\user\PermissionHandler->buildPermissionsYaml()
    > #5 /app/web/core/modules/user/src/Entity/Role.php(202): Drupal\user\PermissionHandler->getPermissions()
    > #6 /app/web/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php(319): Drupal\user\Entity\Role->calculateDependencies()
    > #7 /app/web/core/modules/user/src/Entity/Role.php(179): Drupal\Core\Config\Entity\ConfigEntityBase->preSave(Object(Drupal\user\RoleStorage))
    > #8 /app/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php(562): Drupal\user\Entity\Role->preSave(Object(Drupal\user\RoleStorage))
    > #9 /app/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php(517): Drupal\Core\Entity\EntityStorageBase->doPreSave(Object(Drupal\user\Entity\Role))
    > #10 /app/web/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php(253): Drupal\Core\Entity\EntityStorageBase->save(Object(Drupal\user\Entity\Role))
    > #11 /app/web/core/lib/Drupal/Core/Entity/EntityBase.php(339): Drupal\Core\Config\Entity\ConfigEntityStorage->save(Object(Drupal\user\Entity\Role))
    > #12 /app/web/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php(607): Drupal\Core\Entity\EntityBase->save()
    > #13 /app/web/core/modules/update/update.post_update.php(14): Drupal\Core\Config\Entity\ConfigEntityBase->save()
    > #14 /app/vendor/drush/drush/src/Commands/core/UpdateDBCommands.php(321): update_post_update_add_view_update_notifications_permission(Array)
    > #15 /app/vendor/drush/drush/includes/batch.inc(256): Drush\Commands\core\UpdateDBCommands::updateDoOnePostUpdate('update_post_upd...', Object(DrushBatchContext))
    > #16 /app/vendor/drush/drush/includes/batch.inc(201): _drush_batch_worker()
    > #17 /app/vendor/drush/drush/includes/batch.inc(100): _drush_batch_command('109')
    > #18 /app/vendor/drush/drush/src/Commands/core/UpdateDBCommands.php(175): drush_batch_command('109')
    > #19 [internal function]: Drush\Commands\core\UpdateDBCommands->process('109', Array)
    > #20 /app/vendor/consolidation/annotated-command/src/CommandProcessor.php(257): call_user_func_array(Array, Array)
    > #21 /app/vendor/consolidation/annotated-command/src/CommandProcessor.php(212): Consolidation\AnnotatedCommand\CommandProcessor->runCommandCallback(Array, Object(Consolidation\AnnotatedCommand\CommandData))
    > #22 /app/vendor/consolidation/annotated-command/src/CommandProcessor.php(176): Consolidation\AnnotatedCommand\CommandProcessor->validateRunAndAlter(Array, Array, Object(Consolidation\AnnotatedCommand\CommandData))
    > #23 /app/vendor/consolidation/annotated-command/src/AnnotatedCommand.php(350): Consolidation\AnnotatedCommand\CommandProcessor->process(Object(Symfony\Component\Console\Output\ConsoleOutput), Array, Array, Object(Consolidation\AnnotatedCommand\CommandData))
    > #24 /app/vendor/symfony/console/Command/Command.php(255): Consolidation\AnnotatedCommand\AnnotatedCommand->execute(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
    > #25 /app/vendor/symfony/console/Application.php(1027): Symfony\Component\Console\Command\Command->run(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
    > #26 /app/vendor/symfony/console/Application.php(273): Symfony\Component\Console\Application->doRunCommand(Object(Consolidation\AnnotatedCommand\AnnotatedCommand), Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
    > #27 /app/vendor/symfony/console/Application.php(149): Symfony\Component\Console\Application->doRun(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
    > #28 /app/vendor/drush/drush/src/Runtime/Runtime.php(118): Symfony\Component\Console\Application->run(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
    > #29 /app/vendor/drush/drush/src/Runtime/Runtime.php(48): Drush\Runtime\Runtime->doRun(Array, Object(Symfony\Component\Console\Output\ConsoleOutput))
    > #30 /app/vendor/drush/drush/drush.php(72): Drush\Runtime\Runtime->run(Array)
    > #31 /app/vendor/drush/drush/drush(4): require('/app/vendor/dru...')
    > #32 /app/vendor/bin/drush(117): include('/app/vendor/dru...')
    > #33 {main}
    >  [warning] Drush command terminated abnormally.
    
    In ProcessBase.php line 171:
                                                                                                                            
      Unable to decode output into JSON: Syntax error                                                                       
                                                                                                                            
      TypeError: in_array(): Argument #2 ($haystack) must be of type array, null given in in_array() (line 41 of /app/web/modules/contrib/rabbit_hole/src/BehaviorSettingsManager.php).
  • Status changed to Needs review 12 months ago
  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 8.0 & MySQL 5.7
    last update 12 months ago
    20 pass
  • 🇺🇦Ukraine Matroskeen 🇺🇦 Ukraine, Lutsk

    The backtrace was actually helpful, it showed that there might be some update hooks that eventually will lead to calling the BehaviorSettingsManager::entityTypeIsEnabled() method. It will fail if this method is called before rabbit_hole_update_8103() update hook, when the enabled_entity_types is initialized.

    @hchang can you strat the update from scratch using the patch?
    If it fails, can you send the whole console output so we can see the order of executed update hooks?

    • Matroskeen committed b2765945 on 2.0.x
      Issue #3370953: In_array(): Argument #2 ($haystack) must be of type...
  • Status changed to Fixed 12 months ago
  • 🇺🇦Ukraine Matroskeen 🇺🇦 Ukraine, Lutsk

    There was another report of this issue, so we should probably go ahead and release it as soon as possible.
    Committed to 2.0.x.
    Thanks!

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.69.0 2024