This problem arises when you uncheck the Automatic alias box and type a new alias in. The feed alias doesn't get modified.

This means that you can create a new item (e.g. node) which will have the same generated URL alias as the original alias of the item (node) whose alias we renamed. The node aliases are fine, but pathauto will try to create an alias for the feed, only because the old feed alias didn't get renemaed we have a duplicate.

This is not as unlikely a use case as it may sound - I was manually replacing one node by a new one because I wanted to change the node type, so I renamed the alias for the old one so that the new node would get its new alias automatically --> error.

Full error text follows:

user warning: Duplicate entry 'xxxxxx/feed-en' for key 2 query: INSERT INTO url_alias (src, dst, language) VALUES ('node/25/feed', 'xxxxxx/feed', 'en') in /home/gelstle/public_html/general-ad101/modules/path/path.module on line 112.

This looks similar to one or two other issues in the queue but there may be some differences.

Comments

happysnowmantech’s picture

StatusFileSize
new544.2 KB

I've also seen this problem in a different situation, when using feedapi_mapper to import a feed containing multiple nodes with the same title. I wonder if this is caused by a multithreading/race condition or DB commits happening out of order when updating multiple nodes.

I've attached a screenshot from where I encountered the problem while refreshing a feed. I enabled verbose mode for pathauto and also added some of my own debugging messages. At the bottom, you can see the "Duplicate entry" error message for two of the imported nodes. Previous to that, if you look at where the aliases get created for these nodes, it seems that the alias gets created, but later on _pathauto_alias_exists() returns false for that same alias?

kenorb’s picture

Status: Active » Closed (duplicate)
gpk’s picture

Status: Closed (duplicate) » Active

#251908: FeedAPI: Duplicate entry after feed refresh has been designiated a FeedAPI issue. This issue is nothing to do with FeedAPI, so resetting status.

foripepe’s picture

Status: Active » Needs review

I'm not sure, my bug is the same, but I get an error, after I update a node:

user warning: Duplicate entry 'content/berg/feed-nl' for key 2 query: INSERT INTO url_alias (src, dst, language) VALUES ('node/1159/feed', 'content/berg/feed', 'nl') in /modules/path/path.module on line 112.

I have checked the database, and I saw this:

1180, node/530, content/berg,
1181, node/530/feed, content/berg/feed, nl
4360, node/1159, content/berg, nl

In the pathauto.inc file there is a pathauto_create_alias() function, where the _pathauto_alias_exists() function check, if the destination + language exist or not.
In my case the content/berg + nl is not exist, so it pass through the check. Also the _pathauto_set_alias() function fail, when it tries to set the feed.

My solution:

Index: sites/all/modules/contributions/pathauto/pathauto.inc
===================================================================
--- sites/all/modules/contributions/pathauto/pathauto.inc	(revision 12180)
+++ sites/all/modules/contributions/pathauto/pathauto.inc	(working copy)
@@ -303,9 +303,9 @@
 
   // If the alias already exists, generate a new, hopefully unique, variant
   $separator = variable_get('pathauto_separator', '-');
-  if (_pathauto_alias_exists($alias, $src, $language)) {
+  if (_pathauto_alias_exists($alias, $src, $language) || _pathauto_alias_exists("$alias/feed", $src, $language)) {
     $original_alias = $alias;
-    for ($i = 0; _pathauto_alias_exists(drupal_substr($alias, 0, $maxlength - strlen($i)) . $separator . $i, $src, $language); $i++) {
+    for ($i = 0; _pathauto_alias_exists(drupal_substr($alias, 0, $maxlength - strlen($i)) . $separator . $i, $src, $language) || _pathauto_alias_exists(drupal_substr("$alias/feed", 0, $maxlength - strlen($i)) . $separator . $i, $src, $language); $i++) {
     }
     // Make room for the sequence number
     $alias = drupal_substr($alias, 0, $maxlength - drupal_strlen($i));
EvanDonovan’s picture

This fix worked for me, thanks.

aangel’s picture

It's not working for me. The alias gets replaced with a "-0".

TC44’s picture

#4 worked for me also. Thanks very much foripepe. I do notice that as you save a node, it does append a -0 to the alias. If you save it again, it's removed.

It does kill the errors, so that's the important thing for me.

greggles’s picture

StatusFileSize
new1.31 KB

Here's an actual patch. This makes sense to me.

gpk’s picture

While this should fix the PHP error there still remains, I think, the original issue, that if you manually update an alias, the feed alias doesn't get updated (I was assuming it would/should).

Also note there are one or 2 bugs in path module which can interact with pathauto, e.g. #543608: path.module creates additional alias instead of modifying existing, after node preview which needs a 7.x patch and another referenced there which links on to 2 more. Moral: apparent bugs in pathauto may be bugs in core... though probably not in this case...

TC44’s picture

@gpk - Thanks for the link. I'm going to test your path.module patch also to see if that solves the -0 issue for me.

Cheers

gpk’s picture

@10:
>going to test your path.module patch also to see if that solves...
That patch only fixes a specific problem that occurs on node preview. However one of the linked issues might do the trick. IIRC, path_set_alias() [http://api.drupal.org/api/function/path_set_alias] should do all necessary checks to make sure DB errors don't occur. I think the D5 version behaved nicely, but it was reworked for D6.

dave reid’s picture

Version: 6.x-1.1 » 6.x-1.x-dev
Status: Needs review » Needs work
hass’s picture

+

fdambrosio’s picture

+++

foripepe’s picture

Updated patch for Pathauto 1.4:

diff -r 7fb3b376fa8b sites/all/modules/contributions/pathauto/pathauto.inc
--- a/sites/all/modules/contributions/pathauto/pathauto.inc	Fri Aug 27 12:01:52 2010 +0200
+++ b/sites/all/modules/contributions/pathauto/pathauto.inc	Fri Aug 27 12:02:48 2010 +0200
@@ -331,7 +331,7 @@
   }
 
   // If the alias already exists, generate a new, hopefully unique, variant
-  if (_pathauto_alias_exists($alias, $source, $language)) {
+  if (_pathauto_alias_exists($alias, $source, $language) || _pathauto_alias_exists("$alias/feed", $source, $language)) {
     $maxlength = min(variable_get('pathauto_max_length', 100), _pathauto_get_schema_alias_maxlength());
     $separator = variable_get('pathauto_separator', '-');
     $original_alias = $alias;
@@ -342,7 +342,7 @@
       $unique_suffix = $separator . $i;
       $alias = drupal_substr($original_alias, 0, $maxlength - drupal_strlen($unique_suffix, TRUE)) . $unique_suffix;
       $i++;
-    } while (_pathauto_alias_exists($alias, $source, $language));
+    } while (_pathauto_alias_exists($alias, $source, $language) || _pathauto_alias_exists("$alias/feed", $source, $language));
 
     // Alert the user why this happened.
     _pathauto_verbose(t('The automatically generated alias %original_alias conflicted with an existing alias. Alias changed to %alias.', array(
lindsayo’s picture

I don't know if this is the same thing, but it seems to have some of the same bits in it, so I'm posting here for now.

    user warning: Duplicate entry 'blogs/admin/feed-' for key 2 query: INSERT INTO path_redirect (source, redirect, query, fragment, language, type, last_used) VALUES ('blogs/admin/feed', 'blog/1/feed', '', '', '', 301, 1307128543) in /home/devel/public_html/d6beta/includes/common.inc on line 3538.
    user warning: Duplicate entry 'user/admin/track/feed-' for key 2 query: INSERT INTO path_redirect (source, redirect, query, fragment, language, type, last_used) VALUES ('user/admin/track/feed', 'user/1/track/feed', '', '', '', 301, 1307128543) in /home/devel/public_html/d6beta/includes/common.inc on line 3538.
    warning: array_merge() [function.array-merge]: Argument #2 is not an array in /home/devel/public_html/d6beta/sites/all/modules/token/token.module on line 359.
    warning: array_keys() expects parameter 1 to be array, null given in /home/devel/public_html/d6beta/sites/all/modules/token/token.module on line 362.
    warning: array_values() expects parameter 1 to be array, null given in /home/devel/public_html/d6beta/sites/all/modules/token/token.module on line 363.
    warning: Invalid argument supplied for foreach() in /home/devel/public_html/d6beta/sites/all/modules/token/token.module on line 430.
    warning: Invalid argument supplied for foreach() in /home/devel/public_html/d6beta/sites/all/modules/pathauto/pathauto.inc on line 566.
    user warning: Duplicate entry 'blogs/[user-raw]/feed-' for key 2 query: INSERT INTO path_redirect (source, redirect, query, fragment, language, type, last_used) VALUES ('blogs/[user-raw]/feed', 'blog/1/feed', '', '', '', 301, 1307128543) in /home/devel/public_html/d6beta/includes/common.inc on line 3538.
    user warning: Duplicate entry 'user/[user-raw]/track-0/feed-' for key 2 query: INSERT INTO path_redirect (source, redirect, query, fragment, language, type, last_used) VALUES ('user/[user-raw]/track-0/feed', 'user/1/track/feed', '', '', '', 301, 1307128543) in /home/devel/public_html/d6beta/includes/common.inc on line 3538.

I'm getting that when I view a node from a type that has been auto-aliased, even if the node itself was created before my batch-auto work (and not updated since) and so does not have an automatic alias. I'm not sure what other details you need, I am using path_redirect, and tokens in my menu links, but I don't think that latter datum is relevant.

My thanks and a generous helping of karma are offered. :)

joelpittet’s picture

Issue summary: View changes
StatusFileSize
new1.3 KB

Here's a patch version of #15, thanks @foripepe and @greggles

aangel’s picture

Status: Needs work » Closed (outdated)