{path_redirect}.rid not updated to a serial field from 5.x upgrade
drfuzetto - April 1, 2008 - 21:42
| Project: | Path Redirect |
| Version: | 6.x-1.0-beta1 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | fixed |
Description
I have a path redirect setup for sales/index.html to sales and it returns this:
sales?q=sales/index.html
and of course the page is not found.
I have many other redirects similar to this that are working fine.
All of my directs are permanent and there are no queries or anchors.
Any ideas as to what is going on here?
Deborah fuzetto

#1
Can I ask what server you're using? I'm also curious whether your redirect ends up using
drupal_gotoor the relatively newpath_redirect_goto. You could test that by adding a line like this to the latter function (~line 196):<?phpwatchdog('path_redirect', 'Called path_redirect_goto with $path = ['. $path .'] and $query = ['. $query .'].');
?>
#2
I am using a Linux server.
I added the debug line and it did not show up in my logs. What does this mean? Do I want it to call the function in the module or the Drupal function?
Also after some more testing I found that in the path_redirect_init function it doesn't get to any of the "if" statements under the comment
// only redirect if allow_bypass is off or bypass is not requested
What is the $_GET['redirect'] variable?
#3
Actually, I can't get this module to work at all. The redirects fail every time no matter what 300 setting the redirect is on. I have attempted:
- /node/#
- /url-alias (generated aliases by path auto)
It doesn't error out, there are no errors in the log. It is like the module isn't even turned on. One thing I did notice was when I edited the aliases, the path grew in length each time I saved it. For example:
1. I create the redirect. Redirect /this-is-the-url to random external URL
2. I save the redirect.
3. I click edit.
4. I save again (no changes are made).
5. The url is now: /this-is-the-urlthis-is-the-url
I saved the URLs several times and it grew to:
/this-is-the-urlthis-is-the-urlthis-is-the-urlthis-is-the-urlthis-is-the-urlthis-is-the-urlthis-is-the-urlthis-is-the-urlthis-is-the-url
#4
Can you confirm that you're seeing that behavior in the latest 6.x dev release?
#5
Sorry, the version I am on is the latest 5.x dev. Should I create a new issue?
#6
You may if you like, but I think I know the problem. Could you try out this hastily crafted patch? Sorry, I can't test it myself at the moment, but I'll be working on this tonight with the goal of getting the next release out.
#7
I patched the module and your patch appears to have fixed the problem both the URL redirect and the issue with the growing URL. I will test it on a couple of other sites and see if the patch holds.
And - you rock! Thanks! I thought I was doing something wrong or using the module incorrectly.
#8
Okay, I've committed that patch. It will take a while for the dev version to be regenerated. I'll leave this issue open to hopefully address drfuzetto's problem.
#9
Ummm... this patch never got into a new version for drupal 6. Could you check what's wrong? I just moved my blog from wordpress to drupal 6 and need to set some redirects so everything works right.
I'm getting this error right now.
user warning: Duplicate entry '0' for key 1 query: INSERT INTO path_redirect (path, redirect, query, fragment, type) VALUES ('test', 'testdf', '', '', '301') in /home/.enola/kylemathews/kyle.mathews2000.com/sites/all/modules/path_redirect/path_redirect.module on line 139.#10
Another user with the same problem; am trying to install and use the current dev version for 6.2.
Database is a test site with Drupal 5.7 -> 6.2 upgrade, and I can't create a redirect. Error:
user warning: Duplicate entry '0' for key 2 query: INSERT INTO path_redirect (path, redirect, query, fragment, type) VALUES ('whats-christmas-countdown', 'node/647', '', '', '301') in /home/site2/html/sites/all/modules/path_redirect/path_redirect.module on line 139.
Thanks for looking into this.
Cynthia
#11
I've managed to fix the error, and for me, it wasn't the code, it was the path_redirect table settings that were buggy.
At some point since I first installed the module in Drupal 5, the path_redirect database table changed. Specifically, the old table I was trying to use (originally created in Drupal 5, then upgraded to 6), had incorrect settings.
Specifically, field nid was not set to auto_increment, and fields query and fragment did not allow nulls.
To fix the problem, I uninstalled path_redirect module and manually removed the path_redirect table from the database. Then I reinstalled path_redirect, which installed a new table with the correct field settings.
Then I restored data from a sql dump of the old drupal 5 database. I can now see all my redirects, and add, edit or delete entries properly. It was just a matter of getting the correct field settings and replacing the data.
May help somebody else save a few hours.
#12
Just wanted to report that I had this problem too and this solution fixed it perfectly. Thanks!
#13
Sorry, did you mean 'nid' or 'rid'? In my path_redirect table the field is called 'rid'. (V. 5.x, not 6.x, if that makes a difference.) (Thinking it should be 'rid', for 'redirect ID'.)
#14
Yeah, there is a problem in the 6.x-1.x-dev version where the rid column needs to be changed to be auto_increment.
I'm not sure this is completely the right way to do it, but running this query seemed to solve the problem for me:
alter table path_redirect modify rid int(10) not null auto_increment;#15
Hmm...not sure how to approach this upgrade with a fix.
#16
I'd say update the schema definition and do a db_change_field to make it a serial, no?
#17
Looks like the update will need to be on the 5.x .install since this issue will be affecting those users upgrading from the 5.x to 6.x version of the module.
#18
Alright, I committed a new update that should prepare any 5.x path_redirect table to match the 6.x defined schema.
#19
Automatically closed -- issue fixed for 2 weeks with no activity.
#20
Same problem in D6.9 (after upgrade from D5.15) -- cannot create new redirects and the above error appears :-(
I wonder if there a more elegant solution than having to drop the table etc.
#21
I have this problem also I was redirected from here
http://drupal.org/node/319531
user warning: Duplicate entry 'taxonomy/term/15-' for key 2 query: UPDATE url_alias SET src = 'taxonomy/term/', dst = 'taxonomy/term/15', language = '' WHERE pid = 3 in /var/www/vhosts/nafof.org.uk/httpdocs/modules/path/path.module on line 100.
Rich
#22
#23
@richard.e.morton: If that's the only error you have seen, there's no problem with path_redirect, and instead with core's path.module or pathauto.
@vacilando: Did you upgrade to the latest 5.x-1.x version of path_redirect before you upgraded to Drupal 6? Right now that's the only supported upgrade path that will work.
#24
@Dave Reid -- no, the D5 version was patched after I discovered the problem in D6, so by definition it is impossible for me to patch it in D5. Note this is a problem one does not notice immediately after D6 upgrade - it only surfaces after you want to add redirects. Suggestion: perhaps the D6 version's version could simply be adapted so that when update.php is run, the table is checked for the auto_increment property, and if it's not there, it would be added.
#25
This should be fixed for any users updating after the fix was committed. If you upgraded before, just change the {path_redirect}.rid to an auto-increment or serial column.