comparison core/modules/node/node.admin.inc @ 17:129ea1e6d783

Update, including to Drupal core 8.6.10
author Chris Cannam
date Thu, 28 Feb 2019 13:21:36 +0000
parents 4c8ae668cc8c
children af1871eacc83
comparison
equal deleted inserted replaced
16:c2387f117808 17:129ea1e6d783
33 // We use batch processing to prevent timeout when updating a large number 33 // We use batch processing to prevent timeout when updating a large number
34 // of nodes. 34 // of nodes.
35 if (count($nodes) > 10) { 35 if (count($nodes) > 10) {
36 $batch = [ 36 $batch = [
37 'operations' => [ 37 'operations' => [
38 ['_node_mass_update_batch_process', [$nodes, $updates, $langcode, $load, $revisions]] 38 ['_node_mass_update_batch_process', [$nodes, $updates, $langcode, $load, $revisions]],
39 ], 39 ],
40 'finished' => '_node_mass_update_batch_finished', 40 'finished' => '_node_mass_update_batch_finished',
41 'title' => t('Processing'), 41 'title' => t('Processing'),
42 // We use a single multi-pass operation, so the default 42 // We use a single multi-pass operation, so the default
43 // 'Remaining x of y operations' message will be confusing here. 43 // 'Remaining x of y operations' message will be confusing here.
58 if ($load && $revisions) { 58 if ($load && $revisions) {
59 $node = $storage->loadRevision($node); 59 $node = $storage->loadRevision($node);
60 } 60 }
61 _node_mass_update_helper($node, $updates, $langcode); 61 _node_mass_update_helper($node, $updates, $langcode);
62 } 62 }
63 drupal_set_message(t('The update has been performed.')); 63 \Drupal::messenger()->addStatus(t('The update has been performed.'));
64 } 64 }
65 } 65 }
66 66
67 /** 67 /**
68 * Updates individual nodes when fewer than 10 are queued. 68 * Updates individual nodes when fewer than 10 are queued.
162 * 162 *
163 * @see _node_mass_update_batch_process() 163 * @see _node_mass_update_batch_process()
164 */ 164 */
165 function _node_mass_update_batch_finished($success, $results, $operations) { 165 function _node_mass_update_batch_finished($success, $results, $operations) {
166 if ($success) { 166 if ($success) {
167 drupal_set_message(t('The update has been performed.')); 167 \Drupal::messenger()->addStatus(t('The update has been performed.'));
168 } 168 }
169 else { 169 else {
170 drupal_set_message(t('An error occurred and processing did not complete.'), 'error'); 170 \Drupal::messenger()->addError(t('An error occurred and processing did not complete.'));
171 $message = \Drupal::translation()->formatPlural(count($results), '1 item successfully processed:', '@count items successfully processed:'); 171 $message = \Drupal::translation()->formatPlural(count($results), '1 item successfully processed:', '@count items successfully processed:');
172 $item_list = [ 172 $item_list = [
173 '#theme' => 'item_list', 173 '#theme' => 'item_list',
174 '#items' => $results, 174 '#items' => $results,
175 ]; 175 ];
176 $message .= \Drupal::service('renderer')->render($item_list); 176 $message .= \Drupal::service('renderer')->render($item_list);
177 drupal_set_message($message); 177 \Drupal::messenger()->addStatus($message);
178 } 178 }
179 } 179 }