TypeError: Illegal offset type in Drupal\Core\Entity\EntityStorageBase->load()

Created on 15 March 2023, over 1 year ago
Updated 9 September 2023, about 1 year ago

Problem/Motivation

I'm trying to upgrade my D8 site to D9.5. Composer installation stage completed without any errors. When I'm running `drush updb -y` it fails at `views_post_update_sort_identifier` update hook. On the error log I see if fails due to an issue related to Taxonomy machine name module. Please find the full log below:

❯ fin drush updb -y
 -------- -------------------- ------------- ---------------------------------------------------------------
  Module   Update ID            Type          Description
 -------- -------------------- ------------- ---------------------------------------------------------------
  views    sort_identifier      post-update   Add the identifier option to all sort handler configurations.
  views    title_translations   post-update   Rebuild routes to fix view title translations.
 -------- -------------------- ------------- ---------------------------------------------------------------


 // Do you wish to run the specified pending updates?: yes.

>  [notice] Update started: views_post_update_sort_identifier
>  [warning] Array to string conversion EntityStorageBase.php:315
>  [error]  TypeError: Illegal offset type in Drupal\Core\Entity\EntityStorageBase->load() (line 297 of /var/www/docroot/core/lib/Drupal/Core/Entity/EntityStorageBase.php) #0 /var/www/docroot/modules/contrib/taxonomy_machine_name/src/Plugin/views/filter/TaxonomyIndexMachineName.php(427): Drupal\Core\Entity\EntityStorageBase->load(Array)
> #1 /var/www/docroot/modules/custom/company_name/src/Plugin/views/filter/TaxonomyIndexMachineNameMultiple.php(169): Drupal\taxonomy_machine_name\Plugin\views\filter\TaxonomyIndexMachineName->calculateDependencies()
> #2 /var/www/docroot/core/lib/Drupal/Core/Plugin/PluginDependencyTrait.php(71): Drupal\company_name\Plugin\views\filter\TaxonomyIndexMachineNameMultiple->calculateDependencies()
> #3 /var/www/docroot/core/lib/Drupal/Core/Plugin/PluginDependencyTrait.php(89): Drupal\views\Plugin\views\display\DisplayPluginBase->getPluginDependencies(Object(Drupal\company_name\Plugin\views\filter\TaxonomyIndexMachineNameMultiple))
> #4 [internal function]: Drupal\views\Plugin\views\display\DisplayPluginBase->calculatePluginDependencies(Object(Drupal\company_name\Plugin\views\filter\TaxonomyIndexMachineNameMultiple), 4)
> #5 /var/www/docroot/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php(959): array_walk(Array, Array)
> #6 /var/www/docroot/core/lib/Drupal/Core/Plugin/PluginDependencyTrait.php(71): Drupal\views\Plugin\views\display\DisplayPluginBase->calculateDependencies()
> #7 /var/www/docroot/core/lib/Drupal/Core/Plugin/PluginDependencyTrait.php(89): Drupal\Core\Config\Entity\ConfigEntityBase->getPluginDependencies(Object(Drupal\views\Plugin\views\display\DefaultDisplay))
> #8 /var/www/docroot/core/modules/views/src/Entity/View.php(282): Drupal\Core\Config\Entity\ConfigEntityBase->calculatePluginDependencies(Object(Drupal\views\Plugin\views\display\DefaultDisplay))
> #9 /var/www/docroot/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php(320): Drupal\views\Entity\View->calculateDependencies()
> #10 /var/www/docroot/core/modules/views/src/Entity/View.php(292): Drupal\Core\Config\Entity\ConfigEntityBase->preSave(Object(Drupal\Core\Config\Entity\ConfigEntityStorage))
> #11 /var/www/docroot/core/lib/Drupal/Core/Entity/EntityStorageBase.php(569): Drupal\views\Entity\View->preSave(Object(Drupal\Core\Config\Entity\ConfigEntityStorage))
> #12 /var/www/docroot/core/lib/Drupal/Core/Entity/EntityStorageBase.php(524): Drupal\Core\Entity\EntityStorageBase->doPreSave(Object(Drupal\views\Entity\View))
> #13 /var/www/docroot/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php(253): Drupal\Core\Entity\EntityStorageBase->save(Object(Drupal\views\Entity\View))
> #14 /var/www/docroot/core/lib/Drupal/Core/Entity/EntityBase.php(339): Drupal\Core\Config\Entity\ConfigEntityStorage->save(Object(Drupal\views\Entity\View))
> #15 /var/www/docroot/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php(608): Drupal\Core\Entity\EntityBase->save()
> #16 /var/www/docroot/core/lib/Drupal/Core/Config/Entity/ConfigEntityUpdater.php(192): Drupal\Core\Config\Entity\ConfigEntityBase->save()
> #17 /var/www/docroot/core/lib/Drupal/Core/Config/Entity/ConfigEntityUpdater.php(147): Drupal\Core\Config\Entity\ConfigEntityUpdater->doOne(Object(Drupal\views\Entity\View), Object(Closure))
> #18 /var/www/docroot/core/modules/views/views.post_update.php(88): Drupal\Core\Config\Entity\ConfigEntityUpdater->update(Array, 'view', Object(Closure))
> #19 /var/www/vendor/drush/drush/src/Commands/core/UpdateDBCommands.php(321): views_post_update_sort_identifier(Array)
> #20 /var/www/vendor/drush/drush/includes/batch.inc(261): Drush\Commands\core\UpdateDBCommands::updateDoOnePostUpdate('views_post_upda...', Object(DrushBatchContext))
> #21 /var/www/vendor/drush/drush/includes/batch.inc(206): _drush_batch_worker()
> #22 /var/www/vendor/drush/drush/includes/batch.inc(100): _drush_batch_command('28458')
> #23 /var/www/vendor/drush/drush/src/Commands/core/UpdateDBCommands.php(175): drush_batch_command('28458')
> #24 [internal function]: Drush\Commands\core\UpdateDBCommands->process('28458', Array)
> #25 /var/www/vendor/consolidation/annotated-command/src/CommandProcessor.php(257): call_user_func_array(Array, Array)
> #26 /var/www/vendor/consolidation/annotated-command/src/CommandProcessor.php(212): Consolidation\AnnotatedCommand\CommandProcessor->runCommandCallback(Array, Object(Consolidation\AnnotatedCommand\CommandData))
> #27 /var/www/vendor/consolidation/annotated-command/src/CommandProcessor.php(176): Consolidation\AnnotatedCommand\CommandProcessor->validateRunAndAlter(Array, Array, Object(Consolidation\AnnotatedCommand\CommandData))
> #28 /var/www/vendor/consolidation/annotated-command/src/AnnotatedCommand.php(390): Consolidation\AnnotatedCommand\CommandProcessor->process(Object(Symfony\Component\Console\Output\ConsoleOutput), Array, Array, Object(Consolidation\AnnotatedCommand\CommandData))
> #29 /var/www/vendor/symfony/console/Command/Command.php(255): Consolidation\AnnotatedCommand\AnnotatedCommand->execute(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
> #30 /var/www/vendor/symfony/console/Application.php(1039): Symfony\Component\Console\Command\Command->run(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
> #31 /var/www/vendor/symfony/console/Application.php(275): Symfony\Component\Console\Application->doRunCommand(Object(Consolidation\AnnotatedCommand\AnnotatedCommand), Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
> #32 /var/www/vendor/symfony/console/Application.php(149): Symfony\Component\Console\Application->doRun(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
> #33 /var/www/vendor/drush/drush/src/Runtime/Runtime.php(118): Symfony\Component\Console\Application->run(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
> #34 /var/www/vendor/drush/drush/src/Runtime/Runtime.php(48): Drush\Runtime\Runtime->doRun(Array, Object(Symfony\Component\Console\Output\ConsoleOutput))
> #35 /var/www/vendor/drush/drush/drush.php(72): Drush\Runtime\Runtime->run(Array)
> #36 /var/www/vendor/drush/drush/includes/preflight.inc(18): require('/var/www/vendor...')
> #37 phar:///usr/local/bin/drush/bin/drush.php(143): drush_main()
> #38 /usr/local/bin/drush(14): require('phar:///usr/loc...')

The line 169 on the Custom php class(TaxonomyIndexMachineNameMultiple.php) is the second line of this below code block:

  public function calculateDependencies() {
    $dependencies = parent::calculateDependencies();

    foreach (array_filter($this->options['vid']) as $vid) {
      $vocabulary = $this->vocabularyStorage->load($vid);
      $dependencies[$vocabulary->getConfigDependencyKey()][] = $vocabulary->getConfigDependencyName();
    }

    return $dependencies;
  }

Following are the details of the stack I'm trying to upgrade:
Composer 2.5
PHP 8.1
Drupal 9.5.1
Taxonomy machine name 8.x-1.0-beta6

Could someone please tell me if this is a known issue with the module when it comes to D9.5 or could be an error in my custom code ?.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Version

11.0 🔥

Component
Entity 

Last updated about 5 hours ago

Created by

🇦🇺Australia dynamdilshan

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

Comments & Activities

Production build 0.71.5 2024