drush icon indicating copy to clipboard operation
drush copied to clipboard

Progress Message isn't shown in batch-process command.

Open drudoi opened this issue 11 months ago • 2 comments

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

drudoi avatar Mar 10 '25 15:03 drudoi

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!

harivansh0 avatar Apr 24 '25 17:04 harivansh0

Pr welcome

weitzman avatar Aug 15 '25 02:08 weitzman