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.
| Attachment | Size | Status | Test result | Operations |
|---|---|---|---|---|
| longer_path.patch | 862 bytes | Idle | Failed: Failed to apply patch. | View details | Re-test |

#1
I increased the column size to 256 instead of 255...
Rerolled the patch.
#2
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
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
@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
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
@z.stolar: of course, browsers are capable of handling long URLs, but that's really bad design.
#7
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
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
@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
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
Attached patch modifies the forms (admin and node), and adds an update in system.install.
#12
The last submitted patch failed testing.
#13
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
Rerolled to apply to current D7 HEAD.
#15
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
Thanks smk-ka.
Re-rolled using db_change_field() in the db update function.
#17
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
Waw, do we really need that long URLs?
#19
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
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
That said, please remove that second, blank PHPDoc line:
/**+ * Increase permitted length of url aliases to 255 characters.
+ *
+ */
#22
Fair enough, even though it feels a bit silly. Committed to CVS HEAD.
#23
Automatically closed -- issue fixed for 2 weeks with no activity.
#24
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
#26
Here is a patch for D6 that we have in place and working. Thanks to @emackn for making it a while ago.
#27
Awesome, thanks...
Setting to needs review.