user warning: Duplicate entry 'links_clients-nl' for key 2 query: UPDATE url_alias SET src = 'node/24', dst = 'links_clients', language = 'nl' WHERE dst = 'links_clients' in /home/solaris/public_html/site/modules/path/path.module on line 106.

I have seen this error on different posts but I still do not understand how I can solve the problem.
Everytime I update a content I get this warning, my site is in two languages, english being the default language,
my site works great for the rest...

I would really appreciate a clear instruction to solve this.
I am not a high level programmer so please use normal understandable instructions,
thanks alot,
Marc

Files: 
CommentFileSizeAuthor
#11 path.module.patch1.11 KBclaudiu.cristea
#7 path.module.patch1.1 KBethanw

Comments

marc7777’s picture

Assigned:marc7777» Unassigned

user warning: Duplicate entry 'links_clients-nl' for key 2 query: UPDATE url_alias SET src = 'node/24', dst = 'links_clients', language = 'nl' WHERE dst = 'links_clients' in /home/solaris/public_html/site/modules/path/path.module on line 106.

I have seen this error on different posts but I still do not understand how I can solve the problem.
Everytime I update a content I get this warning, my site is in two languages, english being the default language,
my site works great for the rest...

I would really appreciate a clear instruction to solve this.
I am not a high level programmer so please use normal understandable instructions,
thanks alot,
Marc

Jose Reyero’s picture

Project:Internationalization» Drupal core
Version:6.x-1.x-dev» 6.x-dev
Component:Miscellaneous» path.module

Seems like you are trying to create a duplicate entry for the same alias, language

However, this doesn't seem i18n module related, moving to Drupal/path module

David W’s picture

Same issue here; also a bilingual site (two languages).

The path module doesn't seem to realize that duplicate paths are allowed IF each path is for a different language.

David W’s picture

I think I might have found the issue; line 109 of path.module; the SQL query attempts to update all matching "dst" rows based on the existing "dst", instead of trying to update one row by matching the language.

I've modified the path.module start at line 109:

<?php
     
if ($language) {
         
db_query("UPDATE {url_alias} SET src = '%s', dst = '%s', language = '%s' WHERE dst = '%s' and language = '$language' ", $path, $alias, $language, $alias, $language);
      } else {
         
db_query("UPDATE {url_alias} SET src = '%s', dst = '%s', language = '%s' WHERE dst = '%s'", $path, $alias, $language, $alias);
      }
?>

I've done some testing and everything appears to be working just perfectly...no error message anymore either.

akwala’s picture

Same thing happens if there's only one language -- edit a forum topic, and save causes this:

* user warning: Duplicate entry 'page/development-infrastructure-tasks-october-08-launch-' for key 2 query: INSERT INTO url_alias (src, dst, language) VALUES ('node/16', 'page/development-infrastructure-tasks-october-08-launch', '') in /var/www-sec/mydomain.com/modules/path/path.module on line 112.
* user warning: Duplicate entry 'page/development-infrastructure-tasks-october-08-launch/feed-' for key 2 query: INSERT INTO url_alias (src, dst, language) VALUES ('node/16/feed', 'page/development-infrastructure-tasks-october-08-launch/feed', '') in /var/www-sec/mydomain.com/modules/path/path.module on line 112.

Artem’s picture

I have the same problem as akwala. I fail to reproduce it on a local installation, but on the web *sometimes* (about 20-50% of cases) when updating the post title and therefore changing alias via pathauto I get the following error:

user warning: Duplicate entry 'blog/mattgrommes/my-first-agile-project-part-8-9-things-we-disliked-and-liked-about-scrumworks-' for key 2 query: INSERT INTO url_alias (src, dst, language) VALUES ('node/670', 'blog/mattgrommes/my-first-agile-project-part-8-9-things-we-disliked-and-liked-about-scrumworks', '') in /home/content/A/r/t/ArtemMarchenko/html/symbianexample/modules/path/path.module on line 112.
user warning: Duplicate entry 'blog/mattgrommes/my-first-agile-project-part-8-9-things-we-disliked-and-liked-about-scrumworks/feed-' for key 2 query: INSERT INTO url_alias (src, dst, language) VALUES ('node/670/feed', 'blog/mattgrommes/my-first-agile-project-part-8-9-things-we-disliked-and-liked-about-scrumworks/feed', '') in /home/content/A/r/t/ArtemMarchenko/html/symbianexample/modules/path/path.module on line 112.

Looking at path.module line 112 it looks like path.module incorrectly decided that I am going to add a new alias instead of updating the old one. Maybe drupal_get_path_alias somehow returns the wrong value

ethanw’s picture

Status:Active» Needs review
StatusFileSize
new1.1 KB

Same issue here. Code change above looked like what we were planning on and seems to have fixed the issue. Rolled into a patch, attached.

ethanw’s picture

Whoops. Above patch was compiled against version 7 dev by accident. Latest CVS of v6 seems to have this patch applied.

briel’s picture

this problem have a solution in the setting pages of pathauto module.

claudiu.cristea’s picture

What is the solution? I can find anything there (pathauto settings) to fix this.

This issue is raised by generating the same alias in all languages...

claudiu.cristea’s picture

Category:support» bug
Priority:Normal» Critical
Status:Needs review» Patch (to be ported)
StatusFileSize
new1.11 KB

I've updated the patch in order to use the right syntax of db_query() (using sprintf() placeholders in SQL string instead of variables).

Please apply it to the CVS.

jacobson’s picture

I applied this patch. It did not eliminate the error message. HAJ

jefftrnr’s picture

I get the same error as Artem (comment #6). It seems to occur when I've got more than one alias for the same $path. I realize this isn't ideal for SEO - but this is what the client wants, and the option is available in pathauto to keep old aliases in the system. So, I'd like to remove the user warning. Here's the code I added to fix line 112 in the path module (Drupal ver 6.6).

modules/path/path.module - line 112:

      db_query("INSERT INTO {url_alias} (src, dst, language) VALUES ('%s', '%s', '%s')", $path, $alias, $language);

replaced with:

      if ($result = db_query("SELECT dst FROM {url_alias} WHERE src = '%s' AND language IN('%s', '')", $path, $language)) {
        $aliasArr = array();
          while ($aliasVal = db_fetch_object($result)) {
            $aliasArr[] = $aliasVal->dst;
          }
        if (!in_array($alias,$aliasArr)) db_query("INSERT INTO {url_alias} (src, dst, language) VALUES ('%s', '%s', '%s')", $path, $alias, $language);
      } else {
        db_query("INSERT INTO {url_alias} (src, dst, language) VALUES ('%s', '%s', '%s')", $path, $alias, $language);
      }

Rather than offer a formal patch, I'd like to hear from some others more in the Drupal-know. I've already seen the SEO arguments online for having more than one alias per path - that's clear. But, since removing the user warning is a MUST for me, is this the right way to do it? Looking forward to seeing your comments. Please construct a patch from this if all agree it's worth the effort.

drutube’s picture

What jefftrnr says makes sense and this patch Might work. I'll try the patch and report.

I get this error when I have peek install. It very well may not be this. Peek creates an alternative alias to the node so there are multiple urls. I've also got clone module and have cloned many of the nodes that get this error. So it could be either one.

Here is a sample of the warnings I'm getting.

Duplicate entry 'bid/106/business-website-using-cms/feed-en' for key 2 query: UPDATE url_alias SET src = 'node/106/feed', dst = 'bid/106/business-website-using-cms/feed', language = 'en' WHERE dst = 'bid/106/business-website-using-cms/feed' in /home/binserfo/public_html/modules/path/path.module on line 108.

drutube’s picture

The patch didn't fix it. I must be encountering something else.

user warning: Duplicate entry 'bid/106/business-website-using-cms/feed-en' for key 2 query: UPDATE url_alias SET src = 'node/106/feed', dst = 'bid/106/business-website-using-cms/feed', language = 'en' WHERE dst = 'bid/106/business-website-using-cms/feed' in /home/binserfo/public_html/modules/path/path.module on line 108.

jwilson3’s picture

After updating simplenews.module to beta6 to support translation on newsletters (multilingual site, D6.2). Now when I edit a newsletter description (admin/content/simplenews/types/edit/54) I get:

user warning: Duplicate entry 'taxonomy/term/54-' for key 2 query: INSERT INTO url_alias (src, dst, language) VALUES ('taxonomy/term/', 'taxonomy/term/54', '') in /home/drupal/drupal-6.2/modules/path/path.module on line 112.

NOTE the difference from the above is with a TAXONOMY item not a node, but its beyond me why it complained about "54-". Wheres the Dash coming from? Is that simplenews trying to create translation versions of my newsletter or something?

(In passing I saw that pathauto wanted to update itself to "7" so I just left it and let I run. Dunno if that might have had an effect either)

I added jefftrnr's code replacement, and the error messages went away. :/

jbrauer’s picture

I don't have the time to track this down at the moment but here's the cause in my case:

pathauto was set to leave the old alias and add a new one

the url_alias table looks like:

PID src dst lang
12 node/12 dest2 en
13 node/12 dest-new en

When node 12 is edited the update query generated attempts to update and set dst = "dest-new", lang = "en" where pid = 12

This results in an error on a duplicate key because the dest-new-en key already exists for PID 13. In my case the new destinations are all higher PIDs but the query always takes the lowest PID for any given src in my limited testing.

drutube’s picture

pathauto was set to leave the old alias and add a new one

Changing this to 'do nothing' didn't fix. I mean it is set to leave the old alias alone and do nothing and still I get.

user warning: Duplicate entry 'taxonomy/term/314-' for key 2 query: INSERT INTO url_alias (src, dst, language) VALUES ('taxonomy/term/', 'taxonomy/term/314', '') in /home/binserfo/public_html/modules/path/path.module on line 112.

drutube’s picture

Actually I was wrong. It does work. The patch in number 17 works so far. I had forgotten that I reversed it before.

two2the8’s picture

I have a single-language site, and I get the same problem when editing content. My errors look like those in #16, and happen mostly when I'm editing taxonomy terms. It's unclear to me what the solution is here: should I apply the (non) patch above (#13) & change my pathauto settings? Should I wait for this to get fixed in the next release of Drupal?

neochief’s picture

Status:Patch (to be ported)» Closed (duplicate)

Marking this issue as duplicate, because, part of it (regarding duplicates) is being resolved in #269877: path_set_alias() doesn't account for same alias in different languages (from #69 comment). And the second part can be fixed by another set of patches: #358315: drupal_lookup_path() not respects alias' order.

stoptime’s picture

I was getting this, except on line 112 with Pathauto 6.x-1.2. The quick and dirty solution is to just suppress the error with the "@" symbol:

@db_query("INSERT INTO {url_alias} (src, dst, language) VALUES ('%s', '%s', '%s')", $path, $alias, $language);

ddanier’s picture

This (#11) fixed the issue here, thanks!

klonos’s picture

#11 fixed my issues as well.

#21 marks this as duplicate, so I will also try patches proposed there and report back.