Increasing path length to 255 chars

z.stolar - July 30, 2008 - 08:45
Project:Drupal
Version:6.x-dev
Component:path.module
Category:feature request
Priority:normal
Assigned:Unassigned
Status:needs review
Description

Path table has src and dst limited to 128 chars, while HTTP specification has no limit over the length of a URL.
This patch does not make column size to be infinite, but increases it to 256, to accommodate longer URLs, while keeping the DB sane.

AttachmentSizeStatusTest resultOperations
longer_path.patch862 bytesIdleFailed: Failed to apply patch.View details | Re-test

#1

z.stolar - July 30, 2008 - 10:55

I increased the column size to 256 instead of 255...
Rerolled the patch.

AttachmentSizeStatusTest resultOperations
longer_path.patch862 bytesIdleFailed: Failed to apply patch.View details | Re-test

#2

earnie - July 30, 2008 - 12:59
Status:needs review» needs work

I agree that an arbitrary limit is wrong but 256 is still an arbitrary limit. Is there a reason to not make these a text column? Also, you need to supply an update for the existing tables. And what about the forms?

#3

z.stolar - July 30, 2008 - 13:22

I agree about the other fixes - I'll add them.

regarding the length - a question to those who know MySQL better: how to allow long input (>256chars) and still avoid new lines etc.? Should the validation be on Drupal side?

And what about HTML - can we have a text field longer than 256 chars?

#4

Damien Tournoud - July 30, 2008 - 13:28

@z.stolar: you can have several lines in a VARCHAR, too, there is no technical limitation.

About the limit, I would say that any website having paths longer than 128 characters would be seriously broken, and even more with 256 characters! I'm not sure this is even remotely needed.

#5

z.stolar - July 30, 2008 - 13:45

So regarding new lines, and other characters which are not useful in a URL, we'll do validation during form validation.

@Damien: Why do you think the website may be broken? Even Explorer is capable of very long urls...

#6

Damien Tournoud - July 30, 2008 - 13:49

@z.stolar: of course, browsers are capable of handling long URLs, but that's really bad design.

#7

z.stolar - July 30, 2008 - 14:10

I think Drupal should assist people design their websites properly, but not take decisions for them.
I suggest we put some kind of recommendation to use not-so-long url aliases.
Can you please supply a short explanation of why it is considered bad design, so I'll add it to the path form?

#8

earnie - July 30, 2008 - 15:02

With pathauto, the URL's can be longer than the title of the node plus the length of the content type plus any length of text the user gives before that. I think 128 is just a shy short of good. I think any limit is bad. But we have to compromise in the middle I suppose; however, I don't think 256 is enough compromise and the columns should be set to text.

#9

Damien Tournoud - July 30, 2008 - 15:43

@earnie: well, there is no such thing as "no limit". Resources are *always* scarce. Pathauto should learn (if it doesn't already, I didn't verified) to guarantee that paths do not go over the limit.

I don't really care which limit it is (128 vs. 255), even if 128 looks *really* long already.

For reference, here is how such URL would look like:

This looks like a won't fix to me.

#10

z.stolar - July 30, 2008 - 16:59

I agree it *looks* bad.
But apart from that - why is it wrong?

Aesthetics is a matter of taste.

I think a good advice in the field's description is better than limiting the user. If someone decides to go with too long URLs, he should be noticed about it, not restricted from doing it.

#11

z.stolar - August 1, 2008 - 13:37
Title:Increasing path length to 256 chars» Increasing path length to 255 chars
Status:needs work» needs review

Attached patch modifies the forms (admin and node), and adds an update in system.install.

AttachmentSizeStatusTest resultOperations
longer_paths.patch3.57 KBIdleFailed: Invalid PHP syntax.View details | Re-test

#12

Anonymous (not verified) - November 11, 2008 - 11:25
Status:needs review» needs work

The last submitted patch failed testing.

#13

tootsietorres - February 27, 2009 - 14:07

My 2 cents:

It is bad to limit the path if you are trying to send variables to a search. I have been building websites for Realtors and most use IDX to access the MLS on their websites. If they want a custom search link, 128 chars is really limiting.

#14

jeffschuler - June 6, 2009 - 07:42
Status:needs work» needs review

Rerolled to apply to current D7 HEAD.

AttachmentSizeStatusTest resultOperations
longer_paths_2.patch3.36 KBIdlePassed: 11628 passes, 0 fails, 0 exceptionsView details | Re-test

#15

smk-ka - June 8, 2009 - 10:33
Status:needs review» needs work

I was also running into this issue in the past when using pathauto, +1 for increasing the length to 255 characters.

@jeffschuler
ALTER TABLE is not the correct way to alter tables, use db_change_field() instead.

#16

jeffschuler - June 8, 2009 - 13:59
Status:needs work» needs review

Thanks smk-ka.

Re-rolled using db_change_field() in the db update function.

AttachmentSizeStatusTest resultOperations
longer_paths_3.patch3.42 KBIdleUnable to apply patch longer_paths_3.patchView details | Re-test

#17

deekayen - June 11, 2009 - 04:05
Status:needs review» reviewed & tested by the community

FWIW, I don't see any more issues. Upgrade worked for me. Don't know if there should be a test for checking adding of 254, 255, and 256 char strings to make sure 256 fails, etc.

Anyone else in favor of splitting off to a separate issue to discuss why url_alias is managed in system instead of path?

#18

Dries - June 11, 2009 - 04:20

Waw, do we really need that long URLs?

#19

deekayen - June 11, 2009 - 04:31

I think the answer to that question is another question. Why 128 then? Why not 100 or 200? Those are at least round numbers.

255 at least maxes out a field limit at the db level and gives users more flexibility to use the site as they wish.

#20

sun - June 11, 2009 - 04:57

Path table has src and dst limited to 128 chars, while HTTP specification has no limit over the length of a URL.

We are limiting something that should not have a limit.

Just because Drupal core does not exceed the limit does not mean that there is not a use-case that may be limited by the fake limit we apply.

#21

sun - June 11, 2009 - 04:58
Status:reviewed & tested by the community» needs work

That said, please remove that second, blank PHPDoc line:

/**
+ * Increase permitted length of url aliases to 255 characters.
+ *
+ */

#22

Dries - June 11, 2009 - 04:59
Status:needs work» fixed

Fair enough, even though it feels a bit silly. Committed to CVS HEAD.

#23

System Message - June 25, 2009 - 05:00
Status:fixed» closed

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

#24

will_in_wi - September 28, 2009 - 02:35
Version:7.x-dev» 6.x-dev
Status:closed» patch (to be ported)

Can this be backported to 6.x? I have a use case where I have an external bound link which is 226 chars long. I have a hack in place at the moment which makes it work, but it would be nice to fix this for the current version.

#25

Dave Reid - September 28, 2009 - 03:29
Component:system.module» path.module

#26

febbraro - October 22, 2009 - 13:26

Here is a patch for D6 that we have in place and working. Thanks to @emackn for making it a while ago.

AttachmentSizeStatusTest resultOperations
drupal-6-url-alias-to-255.patch3.67 KBIgnoredNoneNone

#27

jeffschuler - October 22, 2009 - 19:57
Status:patch (to be ported)» needs review

Awesome, thanks...
Setting to needs review.

 
 

Drupal is a registered trademark of Dries Buytaert.