Document that migrations used for stubbing need to deal with empty source values

Created on 14 September 2016, almost 8 years ago
Updated 14 August 2023, about 1 year ago

When a migration defines an entity reference and therefor depends upon another 2nd migration which gets run at a later time (thus not enforced via "migration_dependencies: required: ...") the migration will fail if the 2nd migration has Substr as one of the used plugins.

When the migration runs the entity references are created as stubs. The stubs are created creating a Row with only the target_id filled out, the rest of the values are empty. This stub row is then processed by the 2nd migration. When the 2nd migration defines Substr as the plugin for one of the values the Substr plugin will have to process a NULL value and throw MigrateException('The input value must be a string.');

This background-run of the 2nd migration on a stub row to create the entity-reference in the 1st migration effectively fails the whole migration.

The fix is to check for null on $value. If it is NULL then just return $value (NULL) because there won't be anything for Substr to do on NULL.

πŸ“Œ Task
Status

Active

Version

9.5

Component
MigrationΒ  β†’

Last updated 1 day ago

Created by

πŸ‡§πŸ‡ͺBelgium Jeroen

Live updates comments and jobs are added and updated live.
  • Documentation

    Primarily changes documentation, not code. For Drupal core issues, select the Documentation component instead of using this tag. In general, component selection is preferred over tag selection.

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.

Production build 0.71.5 2024