Commit b2f82629 authored by Allan Chappell's avatar Allan Chappell

Fixing the batch process function.

parent 65c00bc2
views_natural_sort.settings:
path: 'admin/structure/views/settings/views_natural_sort'
base_route: views_ui.settings_basic
defaults:
_form: '\Drupal\views_natural_sort\Form\ConfigurationForm'
_title: 'Views Natural Sort Configuration'
requirements:
_permission: 'administer views'
......@@ -59,6 +59,7 @@ function views_natural_sort_schema() {
* Implements hook_install().
*/
function views_natural_sort_install() {
views_natural_sort_queue_data_for_rebuild();
}
/**
......
......@@ -179,7 +179,7 @@ function views_natural_sort_rebuild_index($queue_name, &$context) {
$sandbox['items_per_batch'] = $config->get('rebuild_items_per_batch');
}
for ($i = 0; $i < $sandbox['items_per_batch'] && $sandbox['current'] < $sandbox['max']; $i++) {
while ($item = $queue->claimItem()) {
if ($item = $queue->claimItem(10)) {
try {
$queue_worker->processItem($item->data);
$queue->deleteItem($item);
......@@ -189,19 +189,15 @@ function views_natural_sort_rebuild_index($queue_name, &$context) {
break;
}
catch (\Exception $e) {
watchdog_exception('npq', $e);
watchdog_exception('views_natural_sort', $e);
}
}
$item = $queue->claimItem(10);
if ($item) {
views_natural_sort_process_index_queue($item->data);
$queue->deleteItem($item);
}
$sandbox['current']++;
}
$results['entries'] = $sandbox['current'];
if ($sandbox['current'] != $sandbox['max']) {
$context['finished'] = $sandbox['current'] / $sandbox['max'];
$context['message'] = t('Processed %current out of %max records.', ['%current' => $sandbox['current'], '%max' => $sandbox['max']]);
}
}
......
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