function drush_node_revision_delete_nrd_delete_prior_revisions_validate in Node Revision Delete 7.3
Same name and namespace in other branches
- 8 node_revision_delete.drush.inc \drush_node_revision_delete_nrd_delete_prior_revisions_validate()
Implements drush_hook_COMMAND_validate().
File
- ./
node_revision_delete.drush.inc, line 437
Code
function drush_node_revision_delete_nrd_delete_prior_revisions_validate() {
$args = func_get_args();
// Check for only 2 arguments.
if (count($args) != 2) {
return drush_set_error('NODE_REVISION_DELETE_INVALID_ARGUMENT', dt('This command use two arguments.'));
}
// Check if the first argument is a valid node id.
$node = node_load($args[0]);
if (!$node) {
return drush_set_error('NODE_REVISION_DELETE_INVALID_ARGUMENT', dt('The first argument @nid is not a valid node id.', array(
'@nid' => $args[0],
)));
}
// Check if the second argument is a valid revision id.
$revisions = node_revision_list($node);
if (!isset($revisions[$args[1]])) {
return drush_set_error('NODE_REVISION_DELETE_INVALID_ARGUMENT', dt('The second argument @vid is not a valid revision id or doesn\'t belong to the node id @nid.', array(
'@vid' => $args[1],
'@nid' => $args[0],
)));
}
// Check if exists prior revisions.
if (!count(_node_revision_delete_get_previous_revisions($args[0], $args[1]))) {
drush_log(dt('There is no revision prior to revision @vid.', array(
'@vid' => $args[1],
)), 'warning');
return FALSE;
}
}