InvalidArgumentException: $string ("Migration @id is busy with another operation: @status") must be a string. in Drupal\Core\StringTranslation\TranslatableMarkup->__construct()
This is happening when display($message, $type = 'status') in MigrateMessage.php (core/modules/migrate/src/MigrateMessage.php) receives a non-rendered TranslatableMarkup instance (rather than a string) as the $message from import() in MigrateExecutable.php (core/modules/migrate/src/MigrateExecutable.php, line 168). There are many instances in MigrateExecutable that call display() with a non-rendered TranslatableMarkup instance, resulting in the error above being thrown by the \Drupal::logger(), which expects a string (MigrateExecutable.php lines 127, 168, 184, 207, 284, 303, 475, 491, and 505). In some cases (such as line 284 of MigrateExecutable.php) the InvalidArgumentException prevents the migration from being set back to STATUS_IDLE (line 287), resulting in a stuck migration at STATUS_IMPORTING.
Has anyone else seen these errors?
Comments
Comment #2
timodwhit commentedYeah, it looks like the migration is passing a translation object instead of a string, which the logger method requires.
There seems to be a quick fix of rendering the message if instance of TranslatableMarkable before passing the messages to the logger.
It might be good to make that fix to the drupal core logger method.
Comment #4
undertext commentedThis bug breaks migrations with 'ultimate_cron' module installed.
Set status to major as this is the wrong usage of Logger API.
Any contrib module with custom logger expects $message to be a string and it should be a string, not TranslatableMarkup.
Comment #5
lobsterr commentedComment #6
lobsterr commented@undertext - Can you provide the steps how I can reproduce this issue ?
After investigation of the code I found the TranslatableMarkup class uses ToStringTrait which implements
if we convert TranslatableMarkup to string the render method will be executed and the correct string will be returned. That exactly what I see right now and I cannot reproduce this case.
Comment #7
wim leersComment #9
heddnIf we can reproduce this, please re-open.