function scald_index_rebuild in scald_index 7
Rebuilds the entire index using the batch API.
1 call to scald_index_rebuild()
- scald_index_rebuild_confirm_form_submit in ./
scald_index.module - Submit function for scald_index_rebuild_confirm_form().
File
- ./
scald_index.module, line 237
Code
function scald_index_rebuild() {
// Deleting old entries.
db_truncate('scald_index')
->execute();
// Run batches of 5 nodes per batch.
$nids = db_query('SELECT nid FROM {node}')
->fetchCol();
$step = 5;
$current = 0;
$i = 0;
$batch_operations = array();
foreach ($nids as $nid) {
if (!isset($batch_operations[$i])) {
$batch_operations[$i] = array(
'scald_index_rebuild_run',
array(
array(
$nid,
),
),
);
}
else {
$batch_operations[$i][1][0][] = $nid;
}
$current++;
if ($current == $step) {
$current = 0;
// Start next batch.
$i++;
}
}
// Execute the batch.
batch_set(array(
'title' => t('Adding existing atom/node references'),
'operations' => $batch_operations,
'init_message' => t('The atom/node association is getting added.'),
'progress_message' => t('Processed @current groups of :step nodes out of @total.', array(
':step' => $step,
)),
'finished' => 'scald_index_rebuild_finished',
));
batch_process('admin/structure/scald/atoms-index');
}