You are here

function redirect_delete_multiple in Redirect 7

Same name and namespace in other branches
  1. 7.2 redirect.module \redirect_delete_multiple()

Delete multiple URL redirects.

Parameters

$rids: An array of redirect IDs to delete.

Related topics

4 calls to redirect_delete_multiple()
redirect_delete in ./redirect.module
Delete a single URL redirect.
redirect_delete_by_path in ./redirect.module
Delete any redirects associated with a path or any of its sub-paths.
redirect_generate_batch_delete in ./redirect.generate.inc
redirect_purge_inactive_redirects in ./redirect.module
Purge inactive redirects from the database.
1 string reference to 'redirect_delete_multiple'
redirect_redirect_operations in ./redirect.module
Implements hook_redirect_operations().

File

./redirect.module, line 1041

Code

function redirect_delete_multiple(array $rids) {
  $transaction = db_transaction();
  if (!empty($rids)) {
    $redirects = redirect_load_multiple($rids);
    try {

      // Let modules react to the individual redirects being deleted.
      foreach ($redirects as $rid => $redirect) {
        module_invoke_all('redirect_delete', $redirect);
        module_invoke_all('entity_delete', $redirect, 'redirect');
      }
      db_delete('redirect')
        ->condition('rid', $rids, 'IN')
        ->execute();
    } catch (Exception $e) {
      $transaction
        ->rollback();
      watchdog_exception('redirect', $e);
      throw $e;
    }

    // Clear the redirect_load_multiple cache.
    entity_get_controller('redirect')
      ->resetCache();
  }
}