function node_import_do_all_tasks in Node import 6
Import a number of rows from all available tasks. Should only be called from within hook_cron() or from a JS callback as this function may take a long time.
The function ends when $count $units have been finished. For example
node_import_do_all_tasks('all');
node_import_do_all_tasks('rows', 10);
node_import_do_all_tasks('bytes', 4096);
node_import_do_all_tasks('ms', 1000);
Parameters
$unit: String. Either 'rows', 'bytes', 'ms' (milliseconds) or 'all'. Defaults to 'all'.
$count: Integer. Number of $units to do. Defaults to 0 (in which case exactly one row will be imported if $unit != 'all').
Return value
Nothing.
2 calls to node_import_do_all_tasks()
- NodeImportTestCase::nodeImportDoAllTasks in tests/
NodeImportTestCase.php - Finish all pending import tasks.
- node_import_cron in ./
node_import.module - Implementation of hook_cron().
File
- ./
node_import.inc, line 799 - Public API of the Node import module.
Code
function node_import_do_all_tasks($unit = 'all', $count = 0) {
global $node_import_can_continue;
$byte_count = 0;
$row_count = 0;
timer_start('node_import:do_all_tasks');
foreach (node_import_list_tasks(TRUE) as $taskid => $task) {
$bytes = $task['file_offset'];
$rows = $task['row_done'] + $task['row_error'];
node_import_do_task($task, $unit, $count);
$byte_count += $task['file_offset'] - $bytes;
$row_count += $task['row_done'] + $task['row_error'] - $rows;
if ($node_import_can_continue && ($unit == 'all' || $unit == 'bytes' && $byte_count < $count || $unit == 'rows' && $row_count < $count || $unit == 'ms' && timer_read('node_import:do_all_tasks') < $count)) {
continue;
}
break;
}
timer_stop('node_import:do_all_tasks');
}