You are here

function _node_revision_delete_get_previous_revisions in Node Revision Delete 7.3

Get all revision that are older than current deleted revision.

Parameters

int $nid: The node id.

int $currently_deleted_revision_id: The current revision.

Return value

array An array with the previous revisions.

4 calls to _node_revision_delete_get_previous_revisions()
drush_node_revision_delete_nrd_delete_prior_revisions in ./node_revision_delete.drush.inc
Callback for nrd-delete-prior-revisions command.
drush_node_revision_delete_nrd_delete_prior_revisions_validate in ./node_revision_delete.drush.inc
Implements drush_hook_COMMAND_validate().
node_revision_delete_form_node_revision_delete_confirm_alter in ./node_revision_delete.module
Implements hook_form_FORM_ID_alter().
_node_revision_delete_node_revision_delete_confirm_submit in ./node_revision_delete.module
Custom submit handler for the revision deletion form.

File

./node_revision_delete.helpers.inc, line 364
Helper functions.

Code

function _node_revision_delete_get_previous_revisions($nid, $currently_deleted_revision_id) {

  // Getting the node.
  $node = node_load($nid);

  // Getting all revisions of the current node, in all languages.
  $revision_ids = node_revision_list($node);

  // Adding a placeholder for the deleted revision, as our custom submit
  // function is executed after the core delete the current revision.
  $revision_ids[$currently_deleted_revision_id] = [];
  $revisions_before = [];
  if (count($revision_ids) > 1) {

    // Ordering the array.
    krsort($revision_ids);

    // Getting the prior revisions.
    $revisions_before = array_slice($revision_ids, array_search($currently_deleted_revision_id, array_keys($revision_ids)) + 1, NULL, TRUE);
  }
  return $revisions_before;
}