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

Beulette created an issue. See original summary.

beulette’s picture

Issue summary: View changes

Status: Needs review » Needs work

The last submitted patch, redirect.module.diff, failed testing.

beulette’s picture

StatusFileSize
new698 bytes
beulette’s picture

Status: Needs work » Needs review
beulette’s picture

StatusFileSize
new694 bytes

Status: Needs review » Needs work

The last submitted patch, 6: 2864727-fix-for-pathauto-loop.patch, failed testing.

beulette’s picture

Status: Needs work » Needs review
StatusFileSize
new727 bytes
beulette’s picture

beulette’s picture

Assigned: Unassigned » beulette
Issue summary: View changes
StatusFileSize
new726 bytes
beulette’s picture

pifagor’s picture

Assigned: beulette » Unassigned
StatusFileSize
new776 bytes

When 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 standards

pifagor’s picture

StatusFileSize
new782 bytes
tomsegarra’s picture

I'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()?

chris matthews’s picture

Status: Needs review » Closed (cannot reproduce)

I'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.