user warning: Duplicate entry 'node-' for key 2 query: INSERT INTO path_redirect (path, redirect, query, fragment, language, type, last_used) VALUES ('node', '2004', '', '', '', 301, 1259735509) in /home/example/public_html/includes/common.inc on line 3468.

This happens when creating a new page. It should not create an entry with path='node' and language='' plus there is already an entry with a path='node' and language=''.

Comments

jackalope’s picture

I'm having the same exact problem, but mine didn't start until I updated to 6.x-1.0-beta6.

Sborsody’s picture

I just got this problem on beta5. I'm trying to edit a previously created redirect so that it points to the actual node instead of the path alias. But there is a mistake in the SQL somehow. The path in the redirect that I'm editing should be 'wpl/' not 'wpl'. The old site has links to 'wpl', 'wpl/', and 'wpl/index.html' that I need to all redirect to 'node/241' on the new site. That's the reason for the duplicate entry.

user warning: Duplicate entry 'wpl-' for key 2 query: UPDATE path_redirect SET path = 'wpl', redirect = 'node/241', query = '', fragment = '', language = '', type = 301, last_used = 1260315076 WHERE rid = 220 in /home/insmark7/www/dev.insmark.com/drupal/includes/common.inc on line 3468.

+-----+------+------------------------------------------+-------+----------+----------+------+------------+
| rid | path | redirect                                 | query | fragment | language | type | last_used  |
+-----+------+------------------------------------------+-------+----------+----------+------+------------+
| 220 | wpl/ | products/cds/wealth-planning-leverage-cd | NULL  | NULL     |          |  301 | 1254765270 |
+-----+------+------------------------------------------+-------+----------+----------+------+------------+

+-----+------+----------+-------+----------+----------+------+------------+
| rid | path | redirect | query | fragment | language | type | last_used  |
+-----+------+----------+-------+----------+----------+------+------------+
| 219 | wpl  | node/241 |       |          |          |  301 | 1260315045 |
+-----+------+----------+-------+----------+----------+------+------------+
dave reid’s picture

Status: Active » Closed (works as designed)

Delete the undesired redirect (for 'wpl/') first then. If you create a redirect for 'wpl' it will also work for 'wpl/' so you don't need to create another one.

peterx’s picture

Status: Closed (works as designed) » Active

#3 is a reply to #2 and and #2 is nothing to do with this issue.

dave reid’s picture

Oh, sorry about that. I think I actually might have fixed this in recent CVS commit. Please test out the 6.x-1.x-dev and see if you still get the error (make sure to check for the erroneous redirects first and remove them).

dave reid’s picture

Status: Active » Postponed (maintainer needs more info)
Torenn’s picture

Yes i confirm it started from beta6 as well, and no, latest dev release doesn't fix it.

hedinfoto’s picture

We are having the same issue
user warning: Duplicate entry 'node-' for key 'source_language' query: INSERT INTO us_path_redirect (source, redirect, query, fragment, language, type, last_used) VALUES ('node', 'about/news-events/blog/Php-errors-rule', '', '', '', 301, 1261443460) in C:\MyDocs\websites\multi-giant-sites\includes\common.inc on line 3467.

version 6 beta 1.

hedinfoto’s picture

Just tried the dev version and got
user warning: Duplicate entry 'node-' for key 'source_language' query: INSERT INTO us_path_redirect (source, redirect, query, fragment, language, type, last_used) VALUES ('node', 'about/news-events/blog/phperrors', '', '', '', 301, 1261452606) in C:\MyDocs\websites\multi-giant-sites\includes\common.inc on line 3467.

ceefour’s picture

I'm also having this problem every time I create a new content.

It seems that the 'source' needs to be the actual node path (like 'node/123') instead of simply 'node' (which usually goes to root/front page) ?

Cynthia Ewer’s picture

subscribing - also experiencing this issue

arcticweb’s picture

Same problem here.

Sborsody’s picture

How are you creating the new content with the redirect? The node has to exist before you can create a redirect for it.

MadOverlord’s picture

I just got this. It happened when I created a node and specifically gave it a name that conflicted with the name of a page generated by a view (because I wanted to override the display of one particular page).

I changed the name of the new page to another value (also in the view's namespace but not matching a valid view) -- no error reported -- and then changed it back (so it again conflicted), and again, no error.

However, a quick check shows this happens on any node create whether it conflicts with a view or not. I just created a dummy page derf/derf and got the error. I don't think I've created any new page nodes on the site in a month or so.

I am running Path redirect 6.x-1.0-beta6 and Pathauto 6.x-2.x-dev (2009-Dec-05)

Cynthia Ewer’s picture

I am seeing these errors with a fresh install, clean database, D 6.15, version 6.x-1.0-beta6. I am not using pathauto.

The error occurs on content creation of all node types.

Sborsody’s picture

This sounds confusing because I'm under the impression that URL redirects are not normally created automatically. The only setting associated with automatic creation is when a url alias is updated (using pathauto). Mind you, I'm not familiar with the inner workings of this module.

dperdue’s picture

I'm running beta5 (because of incompatibilities with Pathauto), not beta6, but I'm also having the problem.

It appears that when you have "Automatically create redirects when URL aliases are changed" checked on the settings page and you create a new node and edit the path alias for that node before the first save, this module creates a redirect from "node" to whatever you entered as the URL alias. It continues to do this with other nodes you create, thus the error message. It only occurs for me on nodes that don't have a Pathauto rule defined.

dave reid’s picture

Status: Postponed (maintainer needs more info) » Fixed

Committed a change to CVS that should fix this bug. Please try the latest code and report back if it fixes this condition.

Christoph Haas’s picture

I just checked out the revision 1.3.2.7.2.96 of the path_redirect.module file and put it into my modules/path_redirect directory. All other files are from the 6.x-1.0-beta6 version.

Creating the node works without any errors now. But clicking on "Edit" fails with this error message:

Fatal error: Unsupported operand types in XXXXXXXXXXX/sites/all/modules/path_redirect/path_redirect.module on line 395

dave reid’s picture

@Christoph Haas: That's because you mixed files from two different versions. You'd need to switch all the files to that changeset/revision.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

jenlampton’s picture

Version: 6.x-1.0-beta5 » 6.x-1.x-dev
Status: Closed (fixed) » Active
StatusFileSize
new506 bytes

I am getting the same error - but for taxonomy. I'm running the dev version from 2010-Jan-09.

user warning: Duplicate entry 'whatever.htm-' for key 2 query: INSERT INTO path_redirect (source, redirect, query, fragment, language, type, last_used) VALUES ('whatever.htm', 'taxonomy/term/27', '', '', '', 301, 1266177632) in /path/to/drupal/includes/common.inc on line 3467.

The error appears the FIRST time I try to re-order terms on the "list terms" page for a vocabulary. The second time I reorder those SAME terms, the error does not appear. If I re-order different terms, I get the error again.

This save triggers hook_taxonomy for each term that is moved in the re-order. And even though all my terms already have redirects, an "INSERT INTO" is triggered, throwing this error.

The issue here is that pathauto does not differentiate between $op = insert and $op = update and in both cases calls
path_redirect_save($redirect). The function path_redirect_save tests $redirect['rid'] to determine weather to update or insert, but when this function is called by pathauto the rid is always NULL, so it always tries to insert instead of updating.

I've added a few lines to retrieve the existing rid before saving the redirect, and the error has disappeared for my use-case and paths are being updated appropriately. It would be interesting to see if this solves the problem for nodes, too.

Patch attached.

Tom Ash’s picture

I get a similar error:

user warning: Duplicate entry 'node-' for key 'source_language' query: INSERT INTO path_redirect (source, redirect, query, fragment, language, type, last_used) VALUES ('node', 'pfblog/green-jobs-for-british-workers', '', '', '', 301, 1266698978) in /home/sant0317/public_html/includes/common.inc on line 3467.

I've tried disabling pathauto as I know there may be incompatibilities with the present version and the problem persists (the above message came on saving a new node after having disabled pathauto.)

(This is using 6.x-1.0-beta6 rather than 6.x-1.x-dev which I see this issue is classed under.)

Tom Ash’s picture

Thinking about it - might this be a Global Redirect issue? It's Global Redirect which automatically created the path redirect which threw the warning above.

Tom Ash’s picture

Peculiarly, this issue seems *not* to arise when aliases are created by Pathauto (though I wouldn't swear to this - am happy to test it out more if the module developers would like me to, I'm currently just waiting to see what they say...)

jenlampton’s picture

@Thomas Ash - have you tried the patch above for path_redirect? I am curious to see if it solves your problem. In my case it was pathauto that was calling a function in path_redirect. If Global Redirect was calling that same function (which I have updated) then perhaps the patch in #22 will solve your problem too.

Curious,
Jen

jhedstrom’s picture

Status: Active » Needs review

The patch in #22 worked for me.

emsearcy’s picture

StatusFileSize
new1.03 KB

My thought about the patch from #22 is that while it would prevent duplicates, I really don't want a redirect from "node" anyhow (#22's patch would allow the first one but not successive ones). In fact, Path Redirect won't even let me create a redirect from "node" in the interface, so I think it would be wise to prevent it from doing so on the backend.

My setup may be overly complicated to know what is influencing what (pathauto, path_redirect, global redirect), but I do know that path_redirect_check_alias_changed() is being called on new nodes with the arg $path="node/". I don't think there should ever be a valid reason to create this redirect (which gets sanitized to just "node" by path_redirect_save()), so I'm just checking for that case.

Note also that this patch correctly declares $base_path to be global so that it looks in the right scope for this (otherwise it will always be ""), and I also added a return FALSE to handle the latter case where where we don't create a redirect (to match the documentation at the top of the function).

Or maybe a better place to put this would be a check for "node" in path_redirect_save() after sanitizing happens?

(Patch is against 6.x-1.0-beta6)

jenlampton’s picture

@emsearcy I think the problem with redirects being created for 'node' was resolved in the latest -dev version. Have you tried that one?

If the 'node' redirect problem is resolved, then I think the patch in #22 should solve the duplicate entry error, and things should be peachy :-)

Jen

JGO’s picture

I just updated to beta 6 and have this error, what is the proper solution?

jenlampton’s picture

@JGO use the dev branch.

agileware’s picture

If you run the current dev version (2010-Mar-02) there is no issue, you don't need to patch it.

Does this issue still need to be open?

JGO’s picture

It seems indeed that the dev solved it.

Tom Ash’s picture

I update to dev based on the above comments and got the following error, any help in dealing with which would be much appreciated:

http://drupal.org/node/737778

sunward’s picture

I obtain the same error when creating a new page. This seemed to happen when I tried to save a page twice (the first save didn't seem to work). I did delete a page, and the error didn't occur on the next new page. It did return again after wards.

francisconi.org’s picture

subscribing - also experiencing this issue
Path redirect 6.x-1.0-beta6

user warning: Duplicate entry 'node-' for key 'source_language' query: INSERT INTO path_redirect (source, redirect, query, fragment, language, type, last_used) VALUES ('node', 'que-es-el-oro-gold-filled', '', '', '', 301, 1271652130) in /var/www/tubisuteria.com.ve/includes/common.inc on line 3477.
mobilemichael’s picture

subscribing

kgthompson’s picture

subscribing

bluesomewhere’s picture

Subscribing.

user warning: Duplicate entry 'node-' for key 2 query: INSERT INTO path_redirect (source, redirect, query, fragment, language, type, last_used) VALUES ('node', 'jello-world', '', '', '', 301, 1274077369) in /path/to/drupal/includes/common.inc on line 3477.

Global Redirect 6.x-1.2
Path redirect 6.x-1.0-beta6
Pathauto 6.x-1.3

JGO’s picture

Yep Joshua R. Simmons something is not very allrighty with all these modules together

willhowlett’s picture

subscribing

WhenInRome’s picture

Same errors--

Duplicate entry 'node-' for key 2 query: INSERT INTO path_redirect (source, redirect, query, fragment, language, type, last_used) VALUES ('node', 'Improve-your-gasmilage-for-the-Enviroment', '', '', '', 301, 1274647451) in /var/www/pressflow6/includes/common.inc on line 3470.

elally’s picture

Subscribing

sergmain’s picture

subscribing

Path redirect 6.x-1.0-beta6
Organic groups 6.x-2.1
Node Reference 6.x-2.x-dev

kettari’s picture

Chances there will be fixing release?

TallDavid’s picture

subscribing Note to self: aft.c

Drupal 6.17
Path redirect: "6.x-1.0-beta6"
Pathauto: "6.x-1.x-dev"
Global redirect: "6.x-1.2"

Will try the latest .dev version of Path Redirect.

dflitner’s picture

Subscribing...

We get this same error message.

Creating a new page with a path in URL path settings will give the error. Creating a new page with no path gives no error. We can then go in and edit the page and add a URL path and it still gives no error.

Not using the URL Redirect option for these pages at all.

Currently:
Drupal 6.16
Path redirect 6.x-1.0-beta6

user warning: Duplicate entry 'node-' for key 2 query: INSERT INTO j9we_path_redirect (source, redirect, query, fragment, language, type, last_used) VALUES ('node', 'access/lending-faq', '', '', '', 301, 1277315325) in path-to-drupal/includes/common.inc on line 3477

When we can upgrade, I'll install the dev version of Path redirect and report back on the outcome.

Anonymous’s picture

subscribing

iamba’s picture

subscribing, same issue

user warning: Duplicate entry 'node-' for key 2 query: INSERT INTO dr_path_redirect (source, redirect, query, fragment, language, type, last_used) VALUES ('node', 'xxxxxxxxx', '', '', '', 301, 1277431345) in /home/xxxxxxxxx/public_test/includes/common.inc on line 3477.

using
Drupal 6.17
Path redirect 6.x-1.0-beta6

not using Pathauto or Global redirect

Not sure why I have a "dr_" prefix in front of "path_redirect"

Bronwyn McL’s picture

Subscribing.

kubala.webdesign’s picture

Do you get that error when you create new node and set path alias , or when you editing existing one?
If when you create - i think 'path redirect' don't get nid of node and try create redirect from node/ to alias.

Try disable "Automatically create redirects when URL aliases are changed." in admin/build/path-redirect/settings, and write action (and append to a trigger after node insert or sthg like that) which add record to path_redirect table AFTER save node (use $context['node']->nid to get node ID).

I have the same problem to solve, but i'm started work 5 minutes ago, I didn't read module source yet, so if my idea have no sense - please forgive me ;)

Sorry for broken english.

Greetengs from Cracov, Poland.
M. Kubala

kubala.webdesign’s picture

StatusFileSize
new623 bytes

my solution for 6.x-1.0-beta6 in attachment.
This is possible to get a nid for new nodes, just add 'insert' statement in hook_nodeapi(..) and modify path_redirect_check_alias_changed(..), but when my version of module added redirect from node/XXX to alias/of/node, I've got information about infinity loops (from path_redirect_goto, I don't understand why url($redirect['redirect']) == url($_GET['q'])).

emilyf’s picture

subscribe

emilyf’s picture

Changes in #52 appear to work for me.

kubala.webdesign’s picture

#846714: Redirect from old path to node/XXX after alias having been removed #6 - another patch - better prevention for duplicates and some additional fixes.
Detailed info in comment.

jhedstrom’s picture

Fix in #52 works for me as well.

dave reid’s picture

Status: Needs review » Fixed

This is already fixed in the latest dev, so marking as fixed.

EDIT: Sorry meant to say 'dev' instead of 'beta'.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.