Exception thrown on Unpublish On Empty process plugin

Created on 8 November 2023, 8 months ago
Updated 9 November 2023, 8 months ago

Problem/Motivation

When running a migration that uses the Unpublish on Empty process plugin, an exception is always thrown.

$ drush orange-dam:migration-run --migration=orange_dam_collection
[notice] Running the Orange DAM - Collection migration from queued data.

[error] TypeError: trim(): Argument #1 ($string) must be of type string, stdClass given in trim() (line 35 of /var/www/html/docroot/modules/contrib/orange_dam/src/Plugin/migrate/process/OrangeDamUnpublishOnEmpty.php) #0 /var/www/html/docroot/modules/contrib/orange_dam/src/Plugin/migrate/process/OrangeDamUnpublishOnEmpty.php(35): trim()
#1 /var/www/html/docroot/core/modules/migrate/src/MigrateExecutable.php(448): Drupal\orange_dam\Plugin\migrate\process\OrangeDamUnpublishOnEmpty->transform()

trim() requires a string, but $row->get(configuration['field']) returns a field
if (trim($row->get($this->configuration['field'])) === '') {

Steps to reproduce

Write a migration that uses the Unpublish on Empty plugin, viz:

      plugin: orange_dam_unpublish_on_empty
      field: my_source_field_name

Crashes every time, no matter the field or the data in it.

Proposed resolution

Check whether the field's value is empty instead of treating it as a string.

πŸ› Bug report
Status

Fixed

Version

1.5

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States apotek

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

Comments & Activities

Production build 0.69.0 2024