entity_generate fails with Error: Call to a member function getConfig() on null in EnitityLookup.php

Created on 16 June 2023, about 1 year ago
Updated 20 June 2023, about 1 year ago

I try to create
- file
- media from that file
using entity_generate.

Within my process section I use:

  # field_background_image:
  # Create thumbnail file and link it to new media file
  _titlebackground_name:
    - plugin: skip_on_empty
      method: process
      source: titlebackground
    - plugin: concat
      source:
        - constants/TITLEBACKGROUND_PREFIX
        - title
  _titlebackground_source_path:
    - plugin: skip_on_empty
      method: process
      source: titlebackground
    - plugin: concat
      source:
        - remote_exhibit_url
        - constants/TITLEBACKGROUND_SOURCE_FOLDER
        - titlebackground
  _titlebackground_destination_path:
    - plugin: skip_on_empty
      method: process
      source: titlebackground
    - plugin: concat
      source:
        - constants/DRUPAL_FILE_DIRECTORY
        - remote_exhibit_slug
        - constants/TITLEBACKGROUND_DEST_FOLDER
        - titlebackground
    - plugin: urlencode
  _titlebackground_file:
    - plugin: skip_on_empty
      method: process
      source: titlebackground
    - plugin: file_copy
      source:
        - '@_titlebackground_source_path'
        - '@_titlebackground_destination_path'

  _titlebackground_fid:
    - plugin: skip_on_empty
      method: process
      source: '@_titlebackground_file'
    - plugin: entity_generate
      access_check: false
      entity_type: file
      value_key: uri
      ignore_case: true
      values:
        filename: titlebackground
        status: '@_status'
        uid: '@_uid'


  # create new media file and link file from above
  field_background_image:
    - plugin: skip_on_empty
      method: process
      source: '@_titlebackground_fid'
    - plugin: entity_generate
      access_check: false
      entity_type: media
      value_key: name
      ignore_case: true
      default_values:
        bundle: 'image'
      values:
        name: '@_titlebackground_name'
        field_image/target_id: '@_titlebackground_fid'
        field_image/alt: '@_titlebackground_name'
        status: '@_status'
        uid: '@_uid'

Which fails with

 [warning] Undefined array key "_titlebackground_fid" EntityLookup.php:172
 [error]  Error: Call to a member function getConfig() on null in Drupal\migrate_plus\Plugin\migrate\process\EntityLookup->determineLookupProperties() (line 172 of /var/www/html/docroot/modules/contrib/migrate_plus/src/Plugin/migrate/process/EntityLookup.php) #0 /var/www/html/docroot/modules/contrib/migrate_plus/src/Plugin/migrate/process/EntityLookup.php(137): Drupal\migrate_plus\Plugin\migrate\process\EntityLookup->determineLookupProperties()
#1 /var/www/html/docroot/modules/contrib/migrate_plus/src/Plugin/migrate/process/EntityGenerate.php(75): Drupal\migrate_plus\Plugin\migrate\process\EntityLookup->transform()
#2 /var/www/html/docroot/core/modules/migrate/src/MigrateExecutable.php(448): Drupal\migrate_plus\Plugin\migrate\process\EntityGenerate->transform()
#3 /var/www/html/docroot/core/modules/migrate/src/MigrateExecutable.php(221): Drupal\migrate\MigrateExecutable->processPipeline()
#4 /var/www/html/vendor/drush/drush/includes/drush.inc(206): Drupal\migrate\MigrateExecutable->import()
#5 /var/www/html/vendor/drush/drush/includes/drush.inc(197): drush_call_user_func_array()
#6 /var/www/html/docroot/modules/contrib/migrate_tools/src/Commands/MigrateToolsCommands.php(953): drush_op()
#7 /var/www/html/docroot/modules/contrib/migrate_tools/src/Commands/MigrateToolsCommands.php(413): Drupal\migrate_tools\Commands\MigrateToolsCommands->executeMigration()
#8 [internal function]: Drupal\migrate_tools\Commands\MigrateToolsCommands->import()
#9 /var/www/html/vendor/consolidation/annotated-command/src/CommandProcessor.php(257): call_user_func_array()
#10 /var/www/html/vendor/consolidation/annotated-command/src/CommandProcessor.php(212): Consolidation\AnnotatedCommand\CommandProcessor->runCommandCallback()
#11 /var/www/html/vendor/consolidation/annotated-command/src/CommandProcessor.php(176): Consolidation\AnnotatedCommand\CommandProcessor->validateRunAndAlter()
#12 /var/www/html/vendor/consolidation/annotated-command/src/AnnotatedCommand.php(390): Consolidation\AnnotatedCommand\CommandProcessor->process()
#13 /var/www/html/vendor/symfony/console/Command/Command.php(255): Consolidation\AnnotatedCommand\AnnotatedCommand->execute()
#14 /var/www/html/vendor/symfony/console/Application.php(1039): Symfony\Component\Console\Command\Command->run()
#15 /var/www/html/vendor/symfony/console/Application.php(275): Symfony\Component\Console\Application->doRunCommand()
#16 /var/www/html/vendor/symfony/console/Application.php(149): Symfony\Component\Console\Application->doRun()
#17 /var/www/html/vendor/drush/drush/src/Runtime/Runtime.php(118): Symfony\Component\Console\Application->run()
#18 /var/www/html/vendor/drush/drush/src/Runtime/Runtime.php(48): Drush\Runtime\Runtime->doRun()
#19 /var/www/html/vendor/drush/drush/drush.php(72): Drush\Runtime\Runtime->run()
#20 /var/www/html/vendor/drush/drush/drush(4): require('...')
#21 /var/www/html/vendor/bin/drush(120): include('...')
#22 {main}.

Trying to debug I can see, that the file is copied to my local server. "_titlebackground_file" returns the public file uri (public://directory/filename.jpg)
Checking EntityLookup.php - line 172 - I see that the raw fieldname "_titlebackground_fid" is passed to the function istead of the URI, which results in
[warning] Undefined array key "_titlebackground_fid" EntityLookup.php:172

Any idea, why this is not working?

πŸ› Bug report
Status

Active

Version

6.0

Component

Plugins

Created by

πŸ‡©πŸ‡ͺGermany vistree

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

Comments & Activities

Production build 0.69.0 2024