Commit b077607f authored by alexpott's avatar alexpott

Issue #2550985 by justAChris, stefan.r: Remove SafeMarkup::set in _batch_test_finished_helper()

parent 8d34a79e
......@@ -257,28 +257,28 @@ function _resultMessages($id) {
switch ($id) {
case 'batch_0':
$messages[] = 'results for batch 0<br>none';
$messages[] = 'results for batch 0<div class="item-list"><ul><li>none</li></ul></div>';
break;
case 'batch_1':
$messages[] = 'results for batch 1<br>op 1: processed 10 elements';
$messages[] = 'results for batch 1<div class="item-list"><ul><li>op 1: processed 10 elements</li></ul></div>';
break;
case 'batch_2':
$messages[] = 'results for batch 2<br>op 2: processed 10 elements';
$messages[] = 'results for batch 2<div class="item-list"><ul><li>op 2: processed 10 elements</li></ul></div>';
break;
case 'batch_3':
$messages[] = 'results for batch 3<br>op 1: processed 10 elements<br>op 2: processed 10 elements';
$messages[] = 'results for batch 3<div class="item-list"><ul><li>op 1: processed 10 elements</li><li>op 2: processed 10 elements</li></ul></div>';
break;
case 'batch_4':
$messages[] = 'results for batch 4<br>op 1: processed 10 elements';
$messages[] = 'results for batch 4<div class="item-list"><ul><li>op 1: processed 10 elements</li></ul></div>';
$messages = array_merge($messages, $this->_resultMessages('batch_2'));
break;
case 'batch_5':
$messages[] = 'results for batch 5<br>op 5: processed 10 elements';
$messages[] = 'results for batch 5<div class="item-list"><ul><li>op 5: processed 10 elements</li></ul></div>';
break;
case 'chained':
......
......@@ -88,7 +88,6 @@ function _batch_test_nested_batch_callback() {
* Provides a common 'finished' callback for batches 1 to 4.
*/
function _batch_test_finished_helper($batch_id, $success, $results, $operations) {
$messages = array("results for batch $batch_id");
if ($results) {
foreach ($results as $op => $op_results) {
$messages[] = 'op '. SafeMarkup::escape($op) . ': processed ' . count($op_results) . ' elements';
......@@ -104,7 +103,20 @@ function _batch_test_finished_helper($batch_id, $success, $results, $operations)
$messages[] = t('An error occurred while processing @op with arguments:<br />@args', array('@op' => $error_operation[0], '@args' => print_r($error_operation[1], TRUE)));
}
drupal_set_message(SafeMarkup::set(implode('<br>', $messages)));
// Use item list template to render the messages.
$error_message = [
'#type' => 'inline_template',
'#template' => 'results for batch {{ batch_id }}{{ errors }}',
'#context' => [
'batch_id' => $batch_id,
'errors' => [
'#theme' => 'item_list',
'#items' => $messages,
],
],
];
drupal_set_message(\Drupal::service('renderer')->renderPlain($error_message));
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment