1 redirect.module redirect_validate(Redirect $redirect, $form, &$form_state)

Validate a redirect.


Redirect $redirect: The Redirect object to be validated.


core/modules/redirect/redirect.module, line 639


function redirect_validate(Redirect $redirect, $form, &$form_state) {
  // Check that there there are no redirect loops.
  if (url($redirect->source) == url($redirect->redirect)) {
    form_set_error('redirect', t('You are attempting to redirect the page to itself. This will result in an infinite loop.'));

  if ($existing = redirect_load_by_hash($redirect->hash)) {
    if ($redirect->rid != $existing->rid) {
      form_set_error('source', t('The source path %source is already being redirected. Do you want to <a href="@edit-page">edit the existing redirect</a>?', array('%source' => redirect_url($redirect->source, $redirect->source_options), '@edit-page' => url('admin/config/urls/redirect/edit/' . $existing->rid))));

  // Allow other modules to validate the redirect.
  foreach (module_implements('redirect_validate') as $module) {
    $function = $module . '_redirect_validate';
    $function($redirect, $form, $form_state);