comparison core/includes/batch.inc @ 18:af1871eacc83

Update to Drupal core 8.7.1
author Chris Cannam
date Thu, 09 May 2019 15:33:08 +0100
parents 129ea1e6d783
children
comparison
equal deleted inserted replaced
17:129ea1e6d783 18:af1871eacc83
41 // Retrieve the current state of the batch. 41 // Retrieve the current state of the batch.
42 if (!$batch) { 42 if (!$batch) {
43 $batch = \Drupal::service('batch.storage')->load($request_id); 43 $batch = \Drupal::service('batch.storage')->load($request_id);
44 if (!$batch) { 44 if (!$batch) {
45 \Drupal::messenger()->addError(t('No active batch.')); 45 \Drupal::messenger()->addError(t('No active batch.'));
46 return new RedirectResponse(\Drupal::url('<front>', [], ['absolute' => TRUE])); 46 return new RedirectResponse(Url::fromRoute('<front>', [], ['absolute' => TRUE])->toString());
47 } 47 }
48 } 48 }
49 49
50 // We need to store the updated batch information in the batch storage after 50 // We need to store the updated batch information in the batch storage after
51 // processing the batch. In order for the error page to work correctly this 51 // processing the batch. In order for the error page to work correctly this
251 function _batch_process() { 251 function _batch_process() {
252 $batch = &batch_get(); 252 $batch = &batch_get();
253 $current_set = &_batch_current_set(); 253 $current_set = &_batch_current_set();
254 // Indicate that this batch set needs to be initialized. 254 // Indicate that this batch set needs to be initialized.
255 $set_changed = TRUE; 255 $set_changed = TRUE;
256 $task_message = '';
256 257
257 // If this batch was marked for progressive execution (e.g. forms submitted by 258 // If this batch was marked for progressive execution (e.g. forms submitted by
258 // \Drupal::formBuilder()->submitForm(), initialize a timer to determine 259 // \Drupal::formBuilder()->submitForm(), initialize a timer to determine
259 // whether we need to proceed with the same batch phase when a processing time 260 // whether we need to proceed with the same batch phase when a processing time
260 // of 1 second has been exceeded. 261 // of 1 second has been exceeded.
274 // definitions. 275 // definitions.
275 if ($set_changed && isset($current_set['file']) && is_file($current_set['file'])) { 276 if ($set_changed && isset($current_set['file']) && is_file($current_set['file'])) {
276 include_once \Drupal::root() . '/' . $current_set['file']; 277 include_once \Drupal::root() . '/' . $current_set['file'];
277 } 278 }
278 279
279 $task_message = $label = ''; 280 $task_message = '';
280 // Assume a single pass operation and set the completion level to 1 by 281 // Assume a single pass operation and set the completion level to 1 by
281 // default. 282 // default.
282 $finished = 1; 283 $finished = 1;
283 284
284 if ($item = $queue->claimItem()) { 285 if ($item = $queue->claimItem()) {
362 '@elapsed' => \Drupal::service('date.formatter')->formatInterval($elapsed / 1000), 363 '@elapsed' => \Drupal::service('date.formatter')->formatInterval($elapsed / 1000),
363 // If possible, estimate remaining processing time. 364 // If possible, estimate remaining processing time.
364 '@estimate' => ($current > 0) ? \Drupal::service('date.formatter')->formatInterval(($elapsed * ($total - $current) / $current) / 1000) : '-', 365 '@estimate' => ($current > 0) ? \Drupal::service('date.formatter')->formatInterval(($elapsed * ($total - $current) / $current) / 1000) : '-',
365 ]; 366 ];
366 $message = strtr($progress_message, $values); 367 $message = strtr($progress_message, $values);
367 if (!empty($task_message)) { 368
368 $label = $task_message; 369 return [$percentage, $message, $task_message];
369 }
370
371 return [$percentage, $message, $label];
372 } 370 }
373 else { 371 else {
374 // If we are not in progressive mode, the entire batch has been processed. 372 // If we are not in progressive mode, the entire batch has been processed.
375 return _batch_finished(); 373 return _batch_finished();
376 } 374 }