function node_pathauto_bulk_update_batch_process in Pathauto 6.2
Same name and namespace in other branches
- 7 pathauto.pathauto.inc \node_pathauto_bulk_update_batch_process()
Batch processing callback; Generate aliases for nodes.
1 string reference to 'node_pathauto_bulk_update_batch_process'
- _node_pathauto in ./
pathauto.pathauto.inc - Implements hook_pathauto().
File
- ./
pathauto.pathauto.inc, line 50 - Pathauto integration for core modules.
Code
function node_pathauto_bulk_update_batch_process(&$context) {
if (!isset($context['sandbox']['current'])) {
$context['sandbox']['count'] = 0;
$context['sandbox']['current'] = 0;
}
$concat = _pathauto_sql_concat("'node/'", 'n.nid');
$sql = "SELECT n.nid FROM {node} n LEFT JOIN {url_alias} ua ON {$concat} = ua.src WHERE ua.src IS NULL AND n.nid > %d ORDER BY n.nid";
$args = array(
$context['sandbox']['current'],
);
// Get the total amount of items to process.
if (!isset($context['sandbox']['total'])) {
$context['sandbox']['total'] = db_result(db_query(_pathauto_sql_count($sql), $args));
// If there are no nodes to update, the stop immediately.
if (!$context['sandbox']['total']) {
$context['finished'] = 1;
return;
}
}
$query = db_query_range($sql, $args, 0, 25);
$nids = array();
while ($nid = db_result($query)) {
$nids[] = $nid;
}
pathauto_node_update_alias_multiple($nids, 'bulkupdate');
$context['sandbox']['count'] += count($nids);
$context['sandbox']['current'] = max($nids);
$context['message'] = t('Updated alias for node @nid.', array(
'@nid' => end($nids),
));
if ($context['sandbox']['count'] >= $context['sandbox']['total']) {
$context['finished'] = 1;
}
else {
$context['finished'] = $context['sandbox']['count'] / $context['sandbox']['total'];
}
}