function redirect_path_delete in Redirect 7
Same name and namespace in other branches
- 7.2 redirect.module \redirect_path_delete()
Implements hook_path_delete().
File
- ./
redirect.module, line 420
Code
function redirect_path_delete($path) {
if (!variable_get('redirect_auto_redirect_delete', FALSE)) {
return;
}
elseif (isset($path['redirect']) && !$path['redirect']) {
return;
}
elseif (empty($path)) {
// @todo Remove this condition and allow $path to use an array type hint
// when http://drupal.org/node/1025904 is fixed.
return;
}
// Redirect from a deleted alias to the system path.
if (!redirect_load_by_source($path['alias'], $path['language']) && drupal_valid_path($path['source'])) {
$redirect = new stdClass();
redirect_object_prepare($redirect);
$redirect->source = $path['alias'];
$redirect->redirect = $path['source'];
$redirect->language = $path['language'];
// Check if the redirect exists before saving.
$hash = redirect_hash($redirect);
$existing = redirect_load_by_hash($hash);
if (!$existing) {
redirect_save($redirect);
}
elseif (property_exists($existing, 'status') && $existing->status == 0) {
$existing->status = 1;
redirect_save($existing);
}
}
}