Progress Message isn't shown in batch-process command.
Describe the bug
Run any batch with default or custom set $batch['progress_message'], neither the message nor percentage is shown.
To Reproduce
Run any batch with drush_backend_batch_process(); in command.
Expected behavior The message or progress bar is shown.
Actual behavior
Long time there is no output (even with "-v" option) if worker doesn't provides any $context['message'], only finish message is shown.
Workaround Unknown
System Configuration
| Q | A |
|---|---|
| Drush version? | 13.3.3.0 |
| Drupal version? | 10.3.11 |
| PHP version | 8.2.26 |
| OS? | Linux/Docker |
Hi @weitzman, It seems like the issue arises because the progress_message in the batch is not being processed properly. Suggested Solution: We could ensure that the progress_message is handled safely before being passed to strtr(). Specifically, if the progress_message is a TranslatableMarkup object, we should extract the untranslated string before applying any placeholder replacements. Here’s how you can modify the code:
$total = $current_set['total'];
$values = [
'@current' => $current,
'@total' => $total,
];
// Get the progress message from the current set.
$progress_message = $current_set['progress_message'];
if ($progress_message instanceof TranslatableMarkup) {
$progress_message = $progress_message->getUntranslatedString();
}
$message = strtr($progress_message, $values);
Drush::logger()->notice(strip_tags($message));
This should resolve the issue where neither the message nor the progress bar is being displayed during the batch process. Let me know if this works or if you need more details!
Pr welcome