I have a really long URL, 294 characters; even longer when I convert symbols into URL safe characters. It gets truncated to 255 characters.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

lemmax’s picture

Same problem here. For example,

http://th.wikipedia.org/wiki/%E0%B9%82%E0%B8%A3%E0%B8%87%E0%B9%80%E0%B8%...

is truncated and thus made useless. It should link to a website with a url in Thai language, and in Thai it's not really that long a URL. The limit should be set to at least 512 characters or preferably more.

pauline_perren’s picture

I'm having this issue too.
Apparently Explorer won't accept URLs longer than 2048 so maybe that could be the cut-off ...

marcp’s picture

The 'database columns' case in link_field_settings() tells CCK how big to make the url field -- it's set to 255.

I only found this issue because folks are asking for longer urls in the userlink queue, and I was checking here to see what link does since it should be the de-facto standard (and since userlink should be built on top of CCK/Link).

Is 255 really big enough?

pauline_perren’s picture

FileSize
1.68 KB

Here is a patch to update the URL length to 2048. You will have to manually update any existing database columns from 255 to 2048 but this patch will cause any new fields created to be the new length. It also allows the longer URLs to be entered via the form when creating new content.

jeffschuler’s picture

Status: Active » Needs review
marcp’s picture

Status: Needs review » Needs work

I suspect this patch won't get accepted without a corresponding hook_update_N() in the .install file.

pauline_perren’s picture

Unfortunately I can't see how to tell which database columns have been generated by this module and need to be automatically updated. Presumably someone who knows the module better would know. Can anyone help with this?

vgarvardt’s picture

I'm having the same problem.

So, What about accepting this patch?
New update link_update_6001 introduced in 6.x-2.6-beta1 updates all link fields with new length.

jeffschuler’s picture

Status: Needs work » Needs review
FileSize
2.97 KB

vgarvardt, I'm confused about how link_update_6001() updates link fields with new length. Sorry if I'm missing something.

I've re-rolled the patch in #4 against 6.x-2.6-beta1, and included a new link.install function: link_update_6200() to update the url column lengths to 2048.

I used link_update_6001() as a model for doing so. Not sure if there's a simpler way to choose the url column... I'm grateful for corrections!

vgarvardt’s picture

Yes, this patch works fine.
It would be great if this patch will be applied in the next release.
Thanks.

dropcube’s picture

Version: 6.x-2.5 » 6.x-2.6
FileSize
3.63 KB

The patch looks good, an it works. Also tested the upgrade function, and all links fields are converted correctly to the new database type. Some minor comments about the patch:

+++ link.install	14 Jun 2009 18:07:05 -0000
@@ -86,3 +86,32 @@
+function link_update_6200() {

Would be good to add some PHPdocs to the function, to indicate the changes being done.

+++ link.module	14 Jun 2009 18:07:06 -0000
@@ -461,11 +466,12 @@
+  $url_max_length = sprintf('%d', URL_MAX_LENGTH);
    $field = $form['#field_info'][$element['#field_name']];

Not required to explicitly typecast this.

+++ link.module	14 Jun 2009 18:07:06 -0000
@@ -461,11 +466,12 @@
-     '#maxlength' => '255',
+     '#maxlength' => $url_max_length,

Constant should be used directly.

The attached patch fixed the above.

Also, it renames the constant URL_MAX_LENGTH to LINK_URL_MAX_LENGTH, which is in the module namespace, like the other constants the module defines.

andrewlevine’s picture

tested this patch on two of our websites that were affected by the bug -- worked fine. Patch looks good to me too. Hoping this gets into 6.x-2.7 -- let me know if there's anything else I can do

andrewlevine’s picture

Status: Needs review » Reviewed & tested by the community

setting as RTBC. let me know if you need anything else to commit this.

dropcube’s picture

Version: 6.x-2.6 » 6.x-2.x-dev
Component: User interface » Code
Assigned: Unassigned » dropcube
Status: Reviewed & tested by the community » Needs review
FileSize
3.67 KB

Updated patch against the 6.x-2.x branch.

coltrane’s picture

Status: Needs review » Reviewed & tested by the community

Patch looks good and applies (with some muddling -- it should be rolled from within the Link module directory) still and it works!

jcfiala’s picture

Assigned: dropcube » jcfiala

Thanks for all the feedback - I'll attempt to apply this patch to cvs in the next few days.

jcfiala’s picture

Status: Reviewed & tested by the community » Fixed

Okay, added the patch, it seemed to work, did a little testing, looked good, added a simpletest which uses the really long url supplied above (thank you), and committed this.

So, all good.

Status: Fixed » Closed (fixed)

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

apanag’s picture

Hello,
when do you plan to release a new version?

thanks,
apanag

jcfiala’s picture

When I'm able to spend the time to get it wrapped up. I've still got a bug that I haven't been able to properly squash yet that I don't want to have in 2.9, and sadly professional duties have kept me really busy.

Plus, I really do need to start on the version for Drupal 7.

apanag’s picture

ΟΚ,

Τhanks for your answer. Keep up the good work.

tinem’s picture

I'm not sure if my problem is the same but my long URL get cut off when using CCK Link and URL showing Google Maps StreetView.

I really need some help because I don't know how to use a patch and if I search in the database I can't find this link_field_settings() ?

My site is going to be showed on a Conference hear in Copenhagen so really need some help at soon as possible, please?

At this site http://www.tinemuller.dk/test_drupal/list_koebenhavn look for the links showing Google Maps API StreetView and click. So it's functioning but NOT with really long URLs. :-(

tinem’s picture

Status: Closed (fixed) » Active
andrewlevine’s picture

Status: Active » Closed (fixed)

bug fixed in the latest dev version of the module. Please don't reopen unless the bug is still there.
http://drupal.org/patch for information on patches

tinem’s picture

Sorry I'm not so used to all this. So can I just download link-6.x-2.x-dev.tar and update module and it should functioning?

Edited: In my table content_type_copenhagen I have a field called:
field_streetview_url - varchar(255)
field_streetview_title - varchar(255)
field_streetview_attributes - mediumtext

Do I also need to change something here, please?

tinem’s picture

Everything is functioning now. Didn't change anything in the database just uploded developer version. THANKS - also got a little help from support IRC from camidoo :-)

andrewlevine’s picture

Just be aware the dev version has not been marked yet as a stable release by the maintainer.

tinem’s picture

Now I have a problem again and I have uploaded the Dev version and all is up-to-date.

I have a problem with the URL for StreetView - it should be like this

http://maps.google.com/maps?f=q&hl=da&geocode=&q=Sankt+Hans+Torv,+N%C3%B8rre+All%C3%A9+2+%40+55.69137,12.56125&ie=UTF8&hq=&hnear=&ll=55.691369,12.561252&spn=0.000841,0.001725&t=h&z=19&layer=c&cbll=55.69139,12.560908&panoid=VFIymPDCZZeAulMTXUlMIg&cbp=12,92.83,,0,6.47

but it is like this

http://maps.google.com/maps?f=q&hl=da&geocode=&q=Sankt+Hans+Torv,+N%C3%B8rre+All%C3%A9+2+%40+55.69137,12.56125&ie=UTF8&hq=&hnear=&ll=55.691369,12.561252&spn=0.000841,0.001725&t=h&z=19&layer=c&cbll=55.69139,12.560908&panoid=VFIymPDCZZeAulMTXUlMIg&cbp=12,92

so .83,,0,6.47 is cut of and even if I paste this after the code and there is room for it the code is deleted when I click the StreetView URL. Can someone help, please?

http://www.tinemuller.dk/test_drupal/node/6

tinem’s picture

I didn't found a solution but I deleted some of the address from:

Sankt Hans Torv, Nørre Allé 2
to
Sankt Hans Torv
and the new URL is now:
http://maps.google.com/maps?f=q&hl=da&geocode=&q=Sankt+Hans+Torv+%40+55.69137,12.56125&ie=UTF8&hq=&hnear=&ll=55.691369,12.561252&spn=0.000841,0.001725&t=h&z=19&layer=c&cbll=55.69139,12.560908&panoid=VFIymPDCZZeAulMTXUlMIg&cbp=12,99.07,,1,4.46
and it's functioning. But I HATE when i can't figure out what the problem was and it's not good that I have to delete some of the address. :-(

You can try it click here on StreetView from InfoWindow http://www.tinemuller.dk/test_drupal/node/6?nid=1219

tinem’s picture

I have some problems with these long links.

I can't update the module from vers. 8 to 9 - it keeps saying that it is vers. 8?

Schema Mismatch

content

    *
      content_type_copenhagen
          o column field_streetview_url - difference on: length
            declared: array('description' => t('TODO: please describe this field!'), 'type' => 'varchar', 'length' => 2048, 'not null' => FALSE)
            actual: array('description' => t('TODO: please describe this field!'), 'type' => 'varchar', 'length' => '255', 'not null' => FALSE)

What is going wrong here. Hope someone can help, please?

jcfiala’s picture

Status: Closed (fixed) » Active

First off, you need to set the status to Active when you're following up on the question.

Secondly, the error is complaining that it's expecting the field to be able to contain 2048 characters, and yet your database is set to only contain 255. I don't have the time to look at the code right now, as I'm heading off to work. I'll see if I can't take a little time this weekend and get back to you.

I realize you're frustrated about not hearing back, but we're all volunteers, remember! :)

tinem’s picture

Thanks for reply. I uploaded 6.x-2.x-dev again which I think I did long time ago but hadn't forgotten. But I still have this message about the table but the color for the link is now green but says Recommended version: 6.x-2.9 (2010-Jun-14)

tinem’s picture

Status: Active » Needs work
jeffschuler’s picture

Status: Needs work » Active

@tinem, did you run update.php after installing 6.x-2.x-dev?

What do you get when you query your site database like this:

SELECT schema_version
FROM system
WHERE name = 'link'

needs work status on an issue [here in the issue queue] is for when a patch under review requires modification. Let's set this issue to back to active since we're not sure where the problem lies.

tinem’s picture

Sorry for all the noise I make but I'm not used to make changes and issues but we all have to learn right and I'm struggling hard. :-)

I remember I changed something as explained earlier in this thread but can't remember what I did. I have vers. 6.x-2.9 installed now and all is up to date and I think if I hadn't installed module Schema I would't have noticed this error and can't figure out if it's important or not?

I pasted your code

SELECT schema_version
FROM system
WHERE name = 'link'

in my phpadmin SQL and it shows schema_version 6002 but when I look under modules which is up to date it mentiones vers. 6.x-1.7 - could this be the problem or?

Should I have made changes to your code?

jeffschuler’s picture

It doesn't look like link_update_6200() from @dropcube's patch in #14 was ever committed.

@jcfiala?

Thomas_Zahreddin’s picture

Assigned: jcfiala » Unassigned
FileSize
1.26 KB

as it seems there is the hook_update_n missing from the patch of comment #14, so i reworte it.

tinem’s picture

So shall I do something and if yes what, please?

tinem’s picture

I still have this problem. Shouldn't it be included in a new versions? I use 6.x-2.9 which I think should be the latest for Drupal 6, right?

When I make this link
http://maps.google.com/maps?f=q&source=s_q&hl=da&geocode=&q=56+09+29.658...

it's cut of to this
http://maps.google.com/maps?f=q&source=s_q&hl=da&geocode=&q=56+09+29.658...

what is missing is this
g&cbp=12,344.98,,0,5.23

I'm surprised that it's should be SO difficult. Know you all are doing this for free but please make this functioning and not a patch which I can't understand, sorry.

tinem’s picture

When I look in phpmyadmin in the content type where the link is NOT functioning it says:
field_streetview_url varchar(255)
field_streetview_title varchar(255)

but if I look in another site made later I see this which I think should be the correct:
field_streetview_url varchar(2048)
field_streetview_title varchar(255)

But can't figure out how to make it like this?

vgarvardt’s picture

@tinem
Try patch from #37

tinem’s picture

Why isn't it included in the updates versions?

tinem’s picture

My host doesn't support SSH which I have read that you need - can't i just change link.install and upload it to the link folder?

sydneyshan’s picture

Doesn't VARCHAR have a limit of 255 characters in < MySQL 5.0.3? Is there any checks for this before defining it as 2048?

I've just manually updated all my _url fields to be 2048 to avoid schema module errors. It would be great if an update function could fix these field definitions automatically.

From http://dev.mysql.com/doc/refman/5.0/en/char.html

Values in VARCHAR columns are variable-length strings. The length can be specified as a value from 0 to 255 before MySQL 5.0.3, and 0 to 65,535 in 5.0.3 and later versions. The effective maximum length of a VARCHAR in MySQL 5.0.3 and later is subject to the maximum row size (65,535 bytes, which is shared among all columns) and the character set used.

jenlampton’s picture

Issue summary: View changes
Status: Active » Fixed

It looks like this was fixed at some point, because people have been complaining about it. See #838902: Row size too large MySQL error when adding multiple link fields to single content type

Status: Fixed » Closed (fixed)

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