In nodesymlink_item_save, there is a routine that constructs a path and then passes it into path_set_alias. The problem is, if you are just saving changes to a node that already have symlinks, this still fires. Drupal then throws an error saying duplicate URLs are trying to be inserted.

I've commented it out for the time being, but it should first check to see that a path doesn't already exist before doing that. Also, is there a way to get this to work with token? Our content works on [menupath-raw], is there a way to get it to do that per link item as well?

Comments

wojtha’s picture

Title: Duplicate URL Entry » "Duplicate URL Entry" error when updating node
Assigned: Unassigned » wojtha
Status: Active » Postponed (maintainer needs more info)

I was trying to reproduce it but without success.

I enabled Pathauto, created couple of nodes with nodesymlinks and edited them. I tried to add/delete nodesymlinks or change nothing and save the node, but I couldn't achieve the "Duplicate URL error".

Please, could you be more specific? What setup are you using?

gpk’s picture

Core shouldn't I think throw a PHP error in this sort of situation. Have a look at this: #228792: ERROR: user warning: Duplicate entry IN: site/modules/path/path.module on line 106.

3Dmusings’s picture

I've run into a variation on this issue. I bumped into this while searching for a work around on this issue: http://drupal.org/node/808002. To gain extra control over my paths I tried manually editing the paths that are generated and saved. Here are some examples:

I have a top menu with: Athletes | Parents | Supporters | Sponsors | Coaches | Athletic Directors

Each of these top menus have many duplicate sublinks. For example, all of them have a link to a "Media" page. I created the page and placed it in the menu under athletes and then used node symlinks to place a link in the other 5 menus. I then went to /admin/build/path/list and modified the paths to be like this:

media_111 - changed to - parents/media
media_112 - changed to - supporters/media
media_113 - changed to - sponsors/media
etc

This was going to be my temporary answer to clean up the paths so I could do some path based logic in my template.php to trigger other site events. However it turns out that every time I edit and then save a page that has symlinks, the symlink paths alias' are regenerated which creates a path conflict. For me I don't get an error I just end up with a new set of alias' for the same sym links every time I save.

Ideally there should be some logic that makes it so that every time a node is edited it doesn't save paths unless the node symlinks have been changed. Or a way to specify the url alias in the "show in more locations" form.

However a quick and easy solution might be to put a check box in the "show in more locations" form, to "disable path generation on save". That way the user could choose if they want to generate new paths. We should save the check boxes state to the database so its remembered.

3Dmusings’s picture

Cool It appears that beta 2 has fixed this issue as well, at least the variation of the issue I mentioned in my above post.

3Dmusings’s picture

Did some additional testing and its working well. If you modify a symlinks generated alias through /admin/build/path/list and then go and edit and save the node with the symlinks it will save it back the way it was before it was modified. This works well as there is no duplication. And now that beta 2 supports path auto with tokens the desired path can be auto generated anyway.

So to summarize: nodesymlinks and their path alias' are still saved each time you edit the node. But it is not a big deal as the nodesymlinks tokens make it easy to get a nice alias for your symlinks each time you save. And if a path alias for the nodesymlink already exists, it updates it, this helps prevent any alias duplication.

Well done Wojtha!

wojtha’s picture

Version: 6.x-1.0-beta1 » 6.x-1.0-beta2
Status: Postponed (maintainer needs more info) » Active

@3Dmusings thanks for a kind critic

This is still the issue, nodesymlinks overwrites aliases each time, when node is saved. Since Beta2 you can minimize this problem using pathauto - relying on automatically generated aliases (as @3Dmusings mentioned). But unfortunatelly custom aliases for nodesymlinks are still being overwritten.

wojtha’s picture

Status: Active » Closed (fixed)

Fixed in 6.x-1.0-beta3 release.