TypeError: Cannot access offset of type string on string in image_entity_presave() line 353 web/core/modules/image/image.module

Created on 30 August 2022, about 2 years ago
Updated 4 June 2024, 3 months ago

Problem/Motivation

When migrating d7_field_instance the migration stops with

TypeError: Cannot access offset of type string on string in image_entity_presave() (line 353 of web/core/modules/image/image.module) #0 [internal function]: image_entity_presave(Object(Drupal\field\Entity\FieldConfig), 'field_config')

Steps to reproduce

This happens when doing a Drupal 7 to Drupal 9 migration with drush or Drupal UI.

I've tried with both PHP8.0 and PHP8.1 - same error.

More from the error log

```
#1 /home/dagedk/folkets/folkets2/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(426): call_user_func_array(Object(Closure), Array)
#2 /home/dagedk/folkets/folkets2/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(405): Drupal\Core\Extension\ModuleHandler->Drupal\Core\Extension\{closure}(Object(Closure), 'image')
#3 /home/dagedk/folkets/folkets2/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(433): Drupal\Core\Extension\ModuleHandler->invokeAllWith('entity_presave', Object(Closure))
#4 /home/dagedk/folkets/folkets2/web/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php(339): Drupal\Core\Extension\ModuleHandler->invokeAll('entity_presave', Array)
#5 /home/dagedk/folkets/folkets2/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php(563): Drupal\Core\Config\Entity\ConfigEntityStorage->invokeHook('presave', Object(Drupal\field\Entity\FieldConfig))
#6 /home/dagedk/folkets/folkets2/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php(517): Drupal\Core\Entity\EntityStorageBase->doPreSave(Object(Drupal\field\Entity\FieldConfig))
#7 /home/dagedk/folkets/folkets2/web/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php(253): Drupal\Core\Entity\EntityStorageBase->save(Object(Drupal\field\Entity\FieldConfig))
#8 /home/dagedk/folkets/folkets2/web/core/lib/Drupal/Core/Entity/EntityBase.php(339): Drupal\Core\Config\Entity\ConfigEntityStorage->save(Object(Drupal\field\Entity\FieldConfig))
#9 /home/dagedk/folkets/folkets2/web/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php(607): Drupal\Core\Entity\EntityBase->save()
#10 /home/dagedk/folkets/folkets2/web/core/modules/migrate/src/Plugin/migrate/destination/EntityConfigBase.php(145): Drupal\Core\Config\Entity\ConfigEntityBase->save()
#11 /home/dagedk/folkets/folkets2/web/core/modules/migrate/src/MigrateExecutable.php(248): Drupal\migrate\Plugin\migrate\destination\EntityConfigBase->import(Object(Drupal\migrate\Row), Array)
#12 /home/dagedk/folkets/folkets2/vendor/drush/drush/includes/drush.inc(122): Drupal\migrate\MigrateExecutable->import()
#13 /home/dagedk/folkets/folkets2/vendor/drush/drush/includes/drush.inc(113): drush_call_user_func_array(Array, Array)
#14 /home/dagedk/folkets/folkets2/vendor/drush/drush/src/Drupal/Commands/core/MigrateRunnerCommands.php(455): drush_op(Array)
#15 [internal function]: Drush\Drupal\Commands\core\MigrateRunnerCommands->executeMigration(Object(Drupal\migrate_drupal\Plugin\migrate\FieldMigration), 'd7_field_instan...', Array)
#16 /home/dagedk/folkets/folkets2/vendor/drush/drush/src/Drupal/Commands/core/MigrateRunnerCommands.php(405): array_walk(Array, Array, Array)
#17 [internal function]: Drush\Drupal\Commands\core\MigrateRunnerCommands->import('d7_field_instan...', Array)
#18 /home/dagedk/folkets/folkets2/vendor/consolidation/annotated-command/src/CommandProcessor.php(257): call_user_func_array(Array, Array)
#19 /home/dagedk/folkets/folkets2/vendor/consolidation/annotated-command/src/CommandProcessor.php(212): Consolidation\AnnotatedCommand\CommandProcessor->runCommandCallback(Array, Object(Consolidation\AnnotatedCommand\CommandData))
#20 /home/dagedk/folkets/folkets2/vendor/consolidation/annotated-command/src/CommandProcessor.php(176): Consolidation\AnnotatedCommand\CommandProcessor->validateRunAndAlter(Array, Array, Object(Consolidation\AnnotatedCommand\CommandData))
#21 /home/dagedk/folkets/folkets2/vendor/consolidation/annotated-command/src/AnnotatedCommand.php(350): Consolidation\AnnotatedCommand\CommandProcessor->process(Object(Symfony\Component\Console\Output\ConsoleOutput), Array, Array, Object(Consolidation\AnnotatedCommand\CommandData))
#22 /home/dagedk/folkets/folkets2/vendor/symfony/console/Command/Command.php(255): Consolidation\AnnotatedCommand\AnnotatedCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#23 /home/dagedk/folkets/folkets2/vendor/symfony/console/Application.php(1027): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#24 /home/dagedk/folkets/folkets2/vendor/symfony/console/Application.php(273): Symfony\Component\Console\Application->doRunCommand(Object(Consolidation\AnnotatedCommand\AnnotatedCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#25 /home/dagedk/folkets/folkets2/vendor/symfony/console/Application.php(149): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#26 /home/dagedk/folkets/folkets2/vendor/drush/drush/src/Runtime/Runtime.php(124): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#27 /home/dagedk/folkets/folkets2/vendor/drush/drush/src/Runtime/Runtime.php(51): Drush\Runtime\Runtime->doRun(Array, Object(Symfony\Component\Console\Output\ConsoleOutput))
#28 /home/dagedk/folkets/folkets2/vendor/drush/drush/drush.php(72): Drush\Runtime\Runtime->run(Array)
#29 /home/dagedk/folkets/folkets2/vendor/drush/drush/drush(4): require('/home/dagedk/fo...')
#30 {main}.
```

πŸ› Bug report
Status

Closed: cannot reproduce

Version

9.4

Component
Image systemΒ  β†’

Last updated about 11 hours ago

Created by

πŸ‡©πŸ‡°Denmark lennart

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

Comments & Activities

Not all content is available!

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

  • πŸ‡ΊπŸ‡ΈUnited States todea

    Circling back to this in case anyone else has the same issue.

    I had one field in our Drupal 7 site that had a default image, causing this problem. I simply removed the default image. Remove the default image via the D7 frontend or modify the value in the database within the field_config_instance table.

    I replaced:
    s:13:"default_image";s:5:"53425";

    with:
    s:13:"default_image";i:0;

  • πŸ‡³πŸ‡±Netherlands ndf Amsterdam

    While running the migration (import) you can patch web/core/modules/image/image.module with

      if ($entity->isSyncing()) {
        return;
      }
    
      // Added temporary fix for #3306941.
      if (!is_array($default_image) || !isset($default_image['uuid'])) {
        return;
      }
      // End fix #3306941.
    
      $uuid = $default_image['uuid'];
    
Production build 0.71.5 2024