function drush_node_revision_delete in Node Revision Delete 7.3
Same name and namespace in other branches
- 8 node_revision_delete.drush.inc \drush_node_revision_delete()
- 7.2 node_revision_delete.drush.inc \drush_node_revision_delete()
Implements drush_COMMANDFILE_COMMANDNAME().
File
- ./
node_revision_delete.drush.inc, line 186
Code
function drush_node_revision_delete() {
$args = func_get_args();
// Checking if we have candidate revisions to delete.
$content_types = node_type_get_names();
$candidates = count(_node_revision_delete_candidates($args[0], $args[1], $args[2], $args[3]));
if (!$candidates) {
$content_type = $content_types[$args[0]] . ' [' . $args[0] . ']';
drush_log(dt('There are no revisions to delete for content type @content_type.', array(
'@content_type' => $content_type,
)), 'warning');
return;
}
$dry_run = isset($args[4]) ? (bool) $args[4] : FALSE;
// Set up the batch job.
$batch = array(
'operations' => array(
array(
'node_revision_delete_batch_process',
array(
$args[0],
$args[1],
$args[2],
$args[3],
$dry_run,
),
),
),
'title' => dt('Node Revision Delete batch job'),
'init_message' => dt('Starting...'),
'error_message' => dt('An error occurred'),
'finished' => 'node_revision_delete_batch_finish',
'file' => drupal_get_path('module', 'node_revision_delete') . '/node_revision_delete.batch.inc',
);
// Checking if this is a dry run.
if ($dry_run) {
drush_log(dt('This is a dry run. No revision will be deleted.'), 'warning');
}
// Start the batch job.
batch_set($batch);
drush_backend_batch_process();
}