Hi,
I had redirect loops problems, so I added this implementation of hook_node_presave in a module.
This hook simply look for a redirection with source is equal to the new path alias of the node, and delete this redirection.
This way, I avoid now the problem of redirection loops when changing my alias to a previously existing alias (meaning existing as a redirection) :
/**
* Implements hook_node_update().
* When saving the path alias, delete any redirection from that path to avoid infinite loops.
*/
function redirect_node_update($node) {
$redirect_list = redirect_load_multiple(FALSE, array('redirect' => $node->path['source']));
foreach ($redirect_list as $rid => $redirect_item){
if ($redirect_item->source == $node->path['alias']){
redirect_delete($rid);
}
}
}
Comments
Comment #2
beulette commentedComment #4
beulette commentedComment #5
beulette commentedComment #6
beulette commentedComment #8
beulette commentedComment #9
beulette commentedComment #10
beulette commentedComment #11
beulette commentedComment #12
pifagorWhen comparing lines, it's worth using a rigorous comparison. And for removal we should use
redirect_delete($redirect_item->rid);I also fixed the coding standardsComment #13
pifagorComment #14
tomsegarra commentedI'm unable to reproduce this issue. hook_path_update() already disables any existing redirect with the same source as a new one. Why is it necessary, in addition, to delete the redirect in hook_node_update()?
Comment #15
chris matthews commentedI'm also unable to reproduce this issue. @Beulette @pifagor, if you can provide the exact steps to reproduce on the latest 7.x-1.x-dev please re-open this issue.