Commit 2444865c authored by generalredneck's avatar generalredneck

Issue #1850224: As a user I would like to allow the use of a queue for field...

Issue #1850224: As a user I would like to allow the use of a queue for field indexing so that installing the module doesn't take forever
parent 82f73f7e
......@@ -128,7 +128,6 @@ function views_natural_sort_rebuild_index_batch_set(array $entry_types = array()
// Queue up all the data that needs to be rebuilt.
module_invoke_all('views_natural_sort_queue_rebuild_data', $entry_type);
}
// Run the queue.
$batch = array(
'operations' => array(array('views_natural_sort_rebuild_index', array())),
......@@ -157,7 +156,7 @@ function views_natural_sort_rebuild_index(&$context) {
for ($i = 0; $i < $sandbox['items_per_batch'] && $sandbox['current'] < $sandbox['max']; $i++) {
$item = $queue->claimItem(10);
if ($item) {
views_natural_sort_store($item->data);
views_natural_sort_process_index_queue($item->data);
$queue->deleteItem($item);
}
$sandbox['current']++;
......
......@@ -175,7 +175,7 @@ function views_natural_sort_days_of_the_week_sort_days($string) {
for ($i = 0; $i < 7; $i++) {
$current_day = ($i + $start) % 7;
$abbreviations = views_natural_sort_days_of_the_week_get_acceptable_day_abbreviations($day_list[$current_day], $used_language);
$translated_day = t('@day', array('@day' => $day_list[$current_day]);
$translated_day = t('@day', array('@day' => $day_list[$current_day]));
$string = preg_replace(
array(
'/\b' . $translated_day . '\b/i',
......
......@@ -153,6 +153,29 @@ function views_natural_sort_entity_delete($entity, $type) {
));
}
/**
* Implements hook_cron_queue_info().
*/
function views_natural_sort_cron_queue_info() {
return array(
'views_natural_sort_index_queue' => array(
'worker callback' => 'views_natural_sort_process_index_queue',
'skip on cron' => TRUE,
),
);
}
/**
* Queue worker callback for views_natural_sort_index_queue.
*
* @see callback_queue_worker
*/
function views_natural_sort_process_index_queue($data) {
if (is_array($data)) {
views_natural_sort_store($data);
}
}
/**
* Store Multiple views_natural_sort entries.
*
......
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