diff -u b/core/modules/system/tests/modules/batch_test/batch_test.callbacks.inc b/core/modules/system/tests/modules/batch_test/batch_test.callbacks.inc --- b/core/modules/system/tests/modules/batch_test/batch_test.callbacks.inc +++ b/core/modules/system/tests/modules/batch_test/batch_test.callbacks.inc @@ -106,9 +106,10 @@ // Use item list template to render the messages. $error_message = [ '#type' => 'inline_template', - '#template' => 'results for batch {{ batch_id }}{{ errors }}', + '#template' => 'results for batch {{ batch_id }} ({{ elapsed }}){{ errors }}', '#context' => [ 'batch_id' => $batch_id, + 'elapsed' => $elapsed, 'errors' => [ '#theme' => 'item_list', '#items' => $messages, @@ -117,6 +118,8 @@ ]; drupal_set_message(\Drupal::service('renderer')->renderPlain($error_message)); + + drupal_set_message('elapsed time: ' . $elapsed); } /** only in patch2: unchanged: --- a/core/lib/Drupal/Core/Form/form.api.php +++ b/core/lib/Drupal/Core/Form/form.api.php @@ -109,12 +109,15 @@ function callback_batch_operation($multiple_params, &$context) { * The value set in $context['results'] by callback_batch_operation(). * @param $operations * If $success is FALSE, contains the operations that remained unprocessed. + * @param $elapsed + * A string which represents the elapsed time for the batch process. */ -function callback_batch_finished($success, $results, $operations) { +function callback_batch_finished($success, $results, $operations, $elapsed) { if ($success) { // Here we do something meaningful with the results. - $message = t("@count items were processed.", [ + $message = t("@count items were processed (@elapsed).", [ '@count' => count($results), + '@elapsed' => $elapsed, ]); $list = [ '#theme' => 'item_list', only in patch2: unchanged: --- a/core/modules/system/tests/src/Functional/Batch/ProcessingTest.php +++ b/core/modules/system/tests/src/Functional/Batch/ProcessingTest.php @@ -265,30 +265,31 @@ public function _resultStack($id, $value = 0) { public function _resultMessages($id) { $messages = []; + $pattern_elapsed = ' \((\d+ min )?\d+ sec\)'; switch ($id) { case 'batch_0': - $messages[] = 'results for batch 0