Object of class Drupal\Core\StringTranslation\TranslationManager could not be converted to string

Created on 2 March 2023, over 1 year ago
Updated 7 February 2024, 10 months ago

Module version 2.0.9
Drupal 8.9.2

I have followed the steps exactly as outlined in the module documentation but I am having an issue where this command fails

drush migrate:duplicate-file-detection 'migration_name'

module name is migrate_files

migrate_plus.migration.migrate_files_accomm_step1.yml

# File to Media Migration configuration for Accomm migration

id: migrate_files_accomm_step1
label: Accomm Media
migration_group: media
source:
  plugin: media_entity_generator
  entity_type: node
  bundle: accomodation
  langcode: en
  field_names:
    - field_images

destination:
  plugin: entity:media

process:
  bundle:
    plugin: default_value
    default_value: image

  # Using the alt tag if available, else the file name.
  name:
    plugin: media_name
    source: file_name

  # This process plugin will skip the whole row if a existing media is found.
  existing_media_file:
    plugin: check_media_duplicate
    source: target_id

  # This process plugin will skip the whole row if a duplicate image is found.
  unique_file_id:
    plugin: check_duplicate
    source: target_id


  # Map the field image
  field_media_image/target_id: target_id
  field_media_image/alt: alt
  field_media_image/title: title

  langcode: langcode


dependencies:
  module:
    - migrate_files
  enforced:
    module:
      - migrate_files

migrate_plus.migration.migrate_files_accomm_step2.yml

# This migration links the newly created media entities with entity reference field on the target bundle.

id: migrate_files_accomm_step2
label: Accomm Mapping
migration_group: media
source:
  plugin: content_entity:node
  bundle: accomodation
  include_translations: false

destination:
  plugin: entity:node

process:
  nid: nid

  type:
    plugin: default_value
    default_value: accomodation
    
  field_images_media:
    plugin: file_id_lookup
    source: field_images
    migration: migrate_files_accomm_step1
    no_stub: true


migration_dependencies:
  optional:
  - migrate_files_accomm_step1

dependencies:
  module:
    - migrate_files
  enforced:
    module:
      - migrate_files

when i run
drush migrate:duplicate-file-detection migrate_files_accomm_step1

I get this error

Array
 [error]  Error: Object of class Drupal\Core\StringTranslation\TranslationManager could not be converted to string in Symfony\Component\Console\Formatter\OutputFormatter->format() (line 133 of /app/vendor/symfony/console/Formatter/OutputFormatter.php) #0 /app/vendor/symfony/console/Output/Output.php(155): Symfony\Component\Console\Formatter\OutputFormatter->format(Object(Drupal\Core\StringTranslation\TranslationManager))
#1 /app/vendor/symfony/console/Output/Output.php(132): Symfony\Component\Console\Output\Output->write(Array, true, 1)
#2 /app/web/modules/contrib/migrate_file_to_media/src/Commands/MediaMigrateCommands.php(303): Symfony\Component\Console\Output\Output->writeln(Object(Drupal\Core\StringTranslation\TranslatableMarkup))
#3 [internal function]: Drupal\migrate_file_to_media\Commands\MediaMigrateCommands->duplicateFileDetection('migrate_files_a...', Array)
#4 /app/vendor/consolidation/annotated-command/src/CommandProcessor.php(257): call_user_func_array(Array, Array)
#5 /app/vendor/consolidation/annotated-command/src/CommandProcessor.php(212): Consolidation\AnnotatedCommand\CommandProcessor->runCommandCallback(Array, Object(Consolidation\AnnotatedCommand\CommandData))
#6 /app/vendor/consolidation/annotated-command/src/CommandProcessor.php(176): Consolidation\AnnotatedCommand\CommandProcessor->validateRunAndAlter(Array, Array, Object(Consolidation\AnnotatedCommand\CommandData))
#7 /app/vendor/consolidation/annotated-command/src/AnnotatedCommand.php(302): Consolidation\AnnotatedCommand\CommandProcessor->process(Object(Symfony\Component\Console\Output\ConsoleOutput), Array, Array, Object(Consolidation\AnnotatedCommand\CommandData))
#8 /app/vendor/symfony/console/Command/Command.php(255): Consolidation\AnnotatedCommand\AnnotatedCommand->execute(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#9 /app/vendor/symfony/console/Application.php(1005): Symfony\Component\Console\Command\Command->run(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#10 /app/vendor/symfony/console/Application.php(255): Symfony\Component\Console\Application->doRunCommand(Object(Consolidation\AnnotatedCommand\AnnotatedCommand), Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#11 /app/vendor/symfony/console/Application.php(148): Symfony\Component\Console\Application->doRun(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#12 /app/vendor/drush/drush/src/Runtime/Runtime.php(118): Symfony\Component\Console\Application->run(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#13 /app/vendor/drush/drush/src/Runtime/Runtime.php(49): Drush\Runtime\Runtime->doRun(Array, Object(Symfony\Component\Console\Output\ConsoleOutput))
#14 /app/vendor/drush/drush/drush.php(72): Drush\Runtime\Runtime->run(Array)
#15 /app/vendor/drush/drush/drush(4): require('/app/vendor/dru...')
#16 {main}.
Error: Object of class Drupal\Core\StringTranslation\TranslationManager could not be converted to string in /app/vendor/symfony/console/Formatter/OutputFormatter.php on line 133 #0 /app/vendor/symfony/console/Output/Output.php(155): Symfony\Component\Console\Formatter\OutputFormatter->format(Object(Drupal\Core\StringTranslation\TranslationManager))
#1 /app/vendor/symfony/console/Output/Output.php(132): Symfony\Component\Console\Output\Output->write(Array, true, 1)
#2 /app/web/modules/contrib/migrate_file_to_media/src/Commands/MediaMigrateCommands.php(303): Symfony\Component\Console\Output\Output->writeln(Object(Drupal\Core\StringTranslation\TranslatableMarkup))
#3 [internal function]: Drupal\migrate_file_to_media\Commands\MediaMigrateCommands->duplicateFileDetection('migrate_files_a...', Array)
#4 /app/vendor/consolidation/annotated-command/src/CommandProcessor.php(257): call_user_func_array(Array, Array)
#5 /app/vendor/consolidation/annotated-command/src/CommandProcessor.php(212): Consolidation\AnnotatedCommand\CommandProcessor->runCommandCallback(Array, Object(Consolidation\AnnotatedCommand\CommandData))
#6 /app/vendor/consolidation/annotated-command/src/CommandProcessor.php(176): Consolidation\AnnotatedCommand\CommandProcessor->validateRunAndAlter(Array, Array, Object(Consolidation\AnnotatedCommand\CommandData))
#7 /app/vendor/consolidation/annotated-command/src/AnnotatedCommand.php(302): Consolidation\AnnotatedCommand\CommandProcessor->process(Object(Symfony\Component\Console\Output\ConsoleOutput), Array, Array, Object(Consolidation\AnnotatedCommand\CommandData))
#8 /app/vendor/symfony/console/Command/Command.php(255): Consolidation\AnnotatedCommand\AnnotatedCommand->execute(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#9 /app/vendor/symfony/console/Application.php(1005): Symfony\Component\Console\Command\Command->run(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#10 /app/vendor/symfony/console/Application.php(255): Symfony\Component\Console\Application->doRunCommand(Object(Consolidation\AnnotatedCommand\AnnotatedCommand), Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#11 /app/vendor/symfony/console/Application.php(148): Symfony\Component\Console\Application->doRun(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#12 /app/vendor/drush/drush/src/Runtime/Runtime.php(118): Symfony\Component\Console\Application->run(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#13 /app/vendor/drush/drush/src/Runtime/Runtime.php(49): Drush\Runtime\Runtime->doRun(Array, Object(Symfony\Component\Console\Output\ConsoleOutput))
#14 /app/vendor/drush/drush/drush.php(72): Drush\Runtime\Runtime->run(Array)
#15 /app/vendor/drush/drush/drush(4): require('/app/vendor/dru...')
#16 {main}
Error: Object of class Drupal\Core\StringTranslation\TranslationManager could not be converted to string in Symfony\Component\Console\Formatter\OutputFormatter->format() (line 133 of /app/vendor/symfony/console/Formatter/OutputFormatter.php).
 [warning] Drush command terminated abnormally.

I dont have any translations at all. As suggested in another issue, I have tried with setting the langcode value to both en and und (which breaks it worse).

Clearly Ive done something wrong, but Ive gone over the steps over and over ensuring not to miss anything.

Any ideas? Help greatly appreciated. Happy yo provide any other info that is required.

πŸ› Bug report
Status

Closed: won't fix

Version

2.0

Component

Code

Created by

πŸ‡¨πŸ‡¦Canada lindsay.wils

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

Comments & Activities

  • Issue created by @lindsay.wils
  • πŸ‡¨πŸ‡¦Canada lindsay.wils

    Any maintainers seen this issue before or have any ideas what might be causing this?

    Ive tried and tried and keep running into this same issue, so now is a blocker for me to upgrade our last D8 > D9 > D10. Would love to hear of any possible direction, happy to provide whatever else you may need.

    Thank you.

  • Status changed to Closed: won't fix over 1 year ago
  • πŸ‡ΊπŸ‡¦Ukraine HitchShock Ukraine

    Hi @lindsaywils. Drupal 8.9 can use some legacy code that doesn't support anymore.
    I'm suggesting you to update the Drupal first to the version 9.5+ and migrate files to media afterwards.
    This is the best way in your case.

    Please, reopen the issue if you will reproduce it again for the actual Drupal version.

  • πŸ‡¨πŸ‡¦Canada lindsay.wils

    Thanks very much for your response, I hadn't even thought of that as an option, just assumed I would need to do this first before upgrading. I will give it a shot in the coming weeks when my workload allows

  • πŸ‡¨πŸ‡¦Canada lindsay.wils

    After finally getting back around to this, upgrading to D9 first did the trick, though there may have also bee some issues with the structure of my migrate yml files in relation to languages. All sort now, great module, made a duanting task far less daunting.

Production build 0.71.5 2024