function redirect_generate_batch_delete in Redirect 7
Same name and namespace in other branches
- 8 redirect.generate.inc \redirect_generate_batch_delete()
- 7.2 redirect.generate.inc \redirect_generate_batch_delete()
1 string reference to 'redirect_generate_batch_delete'
File
- ./
redirect.generate.inc, line 48 - Devel generate integration for the redirect module.
Code
function redirect_generate_batch_delete(array &$context) {
if (empty($context['sandbox'])) {
$context['sandbox'] = array();
$context['sandbox']['progress'] = 0;
$context['sandbox']['current_rid'] = 0;
$context['sandbox']['max'] = db_query('SELECT COUNT(DISTINCT rid) FROM {redirect}')
->fetchField();
}
$limit = 20;
$rids = db_query_range("SELECT rid FROM {redirect} WHERE rid > :rid ORDER BY rid", 0, $limit, array(
':rid' => $context['sandbox']['current_rid'],
))
->fetchCol();
redirect_delete_multiple($rids);
// Update our progress information.
$context['sandbox']['progress'] += count($rids);
$context['sandbox']['current_rid'] = end($rids);
$context['message'] = t('Deleted URL redirect @rid.', array(
'@rid' => end($rids),
));
// Inform the batch engine that we are not finished,
// and provide an estimation of the completion level we reached.
if ($context['sandbox']['progress'] != $context['sandbox']['max']) {
$context['finished'] = $context['sandbox']['progress'] >= $context['sandbox']['max'];
}
}