The maximum length the schema allows for urls is only 128 characters. Urls can be much longer than this.

Comments

theapi’s picture

Status: Active » Needs review
StatusFileSize
new804 bytes

Here's a patch to change the url field to be a text field.

david_garcia’s picture

Issue summary: View changes

Works great. I had failing cron jobs due to data truncating database field length.

grhodes’s picture

Works perfectly!
And considering there is no index on url column, this shouldn't break on any configuration.

mgifford’s picture

@grhodes so is it RTBC?

david_garcia’s picture

I didn't test the update part of the patch because I modified database schema manually.

Someone confirm they have tested the patch "as is" before RTBC.

grhodes’s picture

I actually pasted the update function into my project, ran the update via drush and it works perfectly. And as I was saying there is no index on the url column so it shouldn't break in any case I have knowledge of (but I'm quite new to Drupal).
To answer the question directly, yes it has been reviewed ans tested.

rv0’s picture

Status: Needs review » Needs work

Imho, I dont feel "text" is the correct field type.
The url alias table has varchar 255
varchar is usually also much quicker than text due to the way data is linked in the table

I would recommend increasing the size of the current varchar instead of changing to text.

grhodes’s picture

I agree in theory.

The only downfall I can see of increasing the varchar length over 255 is that some old versions of MySQL don't support it (<5.0.3), which would cut off this update to some users. I don't know if this is a valid couter-argument (because I'm aware Drupal's requirements mention MySQL >= 5.0.15) but it seemed important to mention.

Then, what would be the best length?
Some discussions on this subject mention that url's over 2048 characters are not valid in some of the major browser's and that google's bot has the same sort of limitation.
My proposition would therefore be 2048 to allow maximum flexibility without going to the maximum limit.

rv0’s picture

@grhodes
"Then, what would be the best length?"
varchar(255) imho..

because

menu_router: path varchar(255)
menu_links: link_path varchar(255)
url_alias: alias varchar(255)

Why support longer values than what is possible in core? How would you end up with values longer than that anyway (without hacking core)
This table has 25000 entries at the moment on the site I'm using it on, and this will only grow more.. Keeping size to a reasonable minimum is needed.

grhodes’s picture

I agree, the only reason why I wasn't thinking in this way is that my use case requires url values longer than 255 chars.

I am working on a website that was created using another CMS (which has sent url's to GA that were that were over 255 chars long for about 3 years), and is today powered by Drupal and I need to keep track of page vews since creation.

I am aware that this isn't a common use case so I would understand if this patch wasn't committed, I just wanted to expose that some use cases exist.

extremal’s picture

StatusFileSize
new779 bytes

Agree. The field should be 255.
Here is the patch against latest 7.x-1.x-dev

extremal’s picture

Status: Needs work » Needs review
mgifford’s picture

Patch looks good. I installed it just fine in a fresh instance. Would be good for an existing user to test it with a site with data.

  • marcelovani committed 2354f09 on 7.x-1.x authored by extremal
    Issue #2096937 by theapi, extremal, grhodes, mgifford, david_garcia, rv0...
marcelovani’s picture

Status: Needs review » Fixed

Fixed, thanks

Status: Fixed » Closed (fixed)

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