Allow query strings in "from" paths

rwbgb - September 12, 2007 - 08:19
Project:Path redirect
Version:6.x-1.0-beta4
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:closed
Description

Hi,

I was hoping to use this module to setup redirects from an old website to the new drupal website. Hovever, all of the pages in the old website are of the format "/content.php?CategoryID=1039" or "cs_details.php?CsID=206" etc.

Path redirect currently doesn't support queries in the URL - "You cannot currently include a query in your redirect from path."

If this could be addresses it would be a major help and a good way to round off the path_redirect module.

Thanks,

Ryan

#1

jjeff - September 12, 2007 - 15:25

Yes, this seems like a helpful feature.

I do not have time to code it myself right now, but if anyone wants to submit a patch, I'll be happy to take a look.

#2

rwbgb - September 19, 2007 - 12:25

Hi Jjeff,

We've updated the module and it all seems to be working fine. I have attached the file. If you want to go through it and see what we have done the changes have mainly been made to the init function and the admin pages (to not block questionmarks) and are commented.

If we have any problems I will let you know but this has been in use for over 24 hours and created over 100 redirects already which are all working well.

Regards,

Ryan

www.networkmenus.co.uk

AttachmentSize
path_redirect.module.txt 12.34 KB

#3

HorsePunchKid - October 5, 2007 - 13:24

Hi, Ryan. Any chance you could upload a patch for your modifications?

#4

jjeff - October 5, 2007 - 13:28

Seconded!

#5

HorsePunchKid - October 7, 2007 - 01:40
Title:You cannot currently include a query in your redirect from path» Allow query strings in "from" paths

Here is Ryan's version, in patch form, and with the block that prevented redirects with query strings deleted instead of commented out. I haven't had a chance to test it yet. It looks like there are some things that could be cleaned up a little to match the Drupal code conventions.

AttachmentSize
path_redirect_query_5.patch 1.87 KB

#6

HorsePunchKid - October 7, 2007 - 01:42

And here is another patch--also untested!--which makes it a little clearer what is going on in the patch, I think. I can't vouch for its correctness, just that it's more obvious what it's trying to do. :)

AttachmentSize
path_redirect_query_6.patch 1.39 KB

#7

mariuss - October 8, 2007 - 00:00

It would also be great if there was an API call to add redirects.

Other modules that are importing content from another CMS could use this API to automatically setup all the necessary redirects.

#8

mariuss - October 8, 2007 - 00:07

Created a separate feature request for the API call to add redirects:
http://drupal.org/node/181575

#9

jsmorevis - January 8, 2008 - 22:37
Version:5.x-1.x-dev» 5.x-1.1
Category:feature request» support request

Can somebody please post a patch against 5.x-1.1? Which version is the above path_redirect_query_6.patch made for? -dev? -HEAD?

Thanks very much!

#10

HorsePunchKid - January 20, 2008 - 23:07
Version:5.x-1.1» 5.x-1.x-dev
Category:support request» feature request

#6 was made against something in the DRUPAL-5 branch; I don't know specifically what version. Here is an updated version against the latest 5.x-1.x-dev. I haven't tested it with clean URLs off, which will probably not work. There is a validation warning that will need to be fixed, too.

But this patch does basically work. If I can clean up those problems and get some testing, I'll get this committed. It's a pretty minor change that makes this module much more useful for people migrating to Drupal!

AttachmentSize
path_redirect-5.x-1.x_query_10.patch 1.85 KB

#11

HorsePunchKid - January 20, 2008 - 23:40
Status:active» needs work

This version works with and without clean URLs, it appears. The validation warning I mentioned was from another issue I'm working on, so we can ignore that.

One issue remains to be resolved. If I have a redirect from /foo to /bar defined, it would be very reasonable to expect /foo?jub=jub to get redirected to /bar?jub=jub, or at least to just /bar. In fact, I'd bet people are counting on that behavior in the current version. This patch breaks that.

To preserve that behavior, we could first check for whatever was requested, including the query string, and if that doesn't turn up a match, check for what was requested without the query string. In other words, you'd match the most specific thing you could and redirect accordingly.

AttachmentSize
path_redirect-5.x-1.x_query_11.patch 2.13 KB

#12

HorsePunchKid - January 21, 2008 - 02:30
Status:needs work» needs review

This patch addresses the issue I mentioned in #11 above.

AttachmentSize
path_redirect-5.x-1.x_query_12.patch 2.38 KB

#13

HorsePunchKid - January 22, 2008 - 00:33
Status:needs review» reviewed & tested by the community

#12 doesn't work if you have Drupal installed somewhere other than at the root. This patch fixes that. It works with and without clean URLs, in the root or in a subdirectory.

My only concern about this version is whether or not we can count on Drupal's base_path() being available and accurate during path_redirect_init. It doesn't seem to cause any problems when I fiddle with the "performance" settings, at least.

AttachmentSize
path_redirect-5.x-1.x_query_13.patch 2.69 KB

#14

bdragon - January 25, 2008 - 21:28

subscribing

#15

HorsePunchKid - January 26, 2008 - 23:37
Status:reviewed & tested by the community» fixed

Committed! The 6.x branch is back up to date with the changes in the 5.x branch, too. Nothing for 4.x, unfortunately.

#16

Anonymous (not verified) - February 9, 2008 - 23:41
Status:fixed» closed

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

#17

sinasalek - September 10, 2009 - 14:15
Version:5.x-1.x-dev» 6.x-1.0-beta4

I think there is still a bug, i have a multilingual website with drupal 6. path redirect does not redirect path(s) which only include for example ?id=5. i checked the source code and realized that the problem is because of the following code :

<?php
$args
[':path_query'] = $_GET['q'] .'?'. $path['query'];
?>

I removed $_GET['q']. and the problem fixed.
<?php
$args
[':path_query'] = '?'. $path['query'];
?>

Would you please apply this change.

#18

sinasalek - September 11, 2009 - 09:25
Status:closed» active

#19

Dave Reid - November 4, 2009 - 06:23
Status:active» closed

@sinasalek: That completely ruins the SQL and should not be used. Please file a new issue instead of opening up one that's been closed since Feb 2008.

 
 

Drupal is a registered trademark of Dries Buytaert.