WordPress.org

Make WordPress Core

Opened 10 years ago

Closed 6 years ago

#12264 closed defect (bug) (fixed)

links truncated: link_url column in wp_links table -- datatype too small

Reported by: goto10 Owned by: nacin
Milestone: 3.7 Priority: normal
Severity: normal Version: 2.9.2
Component: General Keywords: has-patch commit
Focuses: Cc:

Description

Here is my original post about the issue: http://wordpress.org/support/topic/365540?replies=3

In short, the link_url column in the wp_links table has a datatype of VARCHAR(255). As far as I know, there is no pre-defined limit to the length of a URL. However, browsers typically enforce their own practical limits, the shortest of which is much larger than the 255 character limit that WP is enforcing. Entering urls longer than 255 characters causes them to be truncated.

I tried altering the table so that link_url has a datatype of VARCHAR(1024). This allowed me to use much larger links without them being cut off. Therefore, I believe that the limiting factor is the DB and not some other code within WP.

Attachments (4)

12264.patch (567 bytes) - added by SergeyBiryukov 8 years ago.
12264.2.patch (831 bytes) - added by vinod dalvi 6 years ago.
refresh of original patch along a new patch for #17296.
12264.3.patch (3.6 KB) - added by vinod dalvi 6 years ago.
New patch along the lines of ticket:17296:17296.2.patch
12264.diff (3.3 KB) - added by johnbillion 6 years ago.

Download all attachments as: .zip

Change History (13)

#1 @dd32
10 years ago

  • Keywords 2nd-opinion dev-feedback added; links wp_links removed
  • Milestone changed from Unassigned to Future Release

Strangely enough, 255 is actually the correct url length limitation.

That being said, Its rare for modern applications to adhere to that standard.

Is there any particular reason this could not be stored as some form of TEXT field, or is it simply more memory efficient to use a VARCHAR instead?

#2 @goto10
10 years ago

Thank you for your response dd32.

Because I keep getting contradictory information on the HTTP URI length specification, I have decided to look at the official docs:

http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html
3.2.1 General Syntax (paragraph 2 and accompanying note)

In short, according to rfc2616: "The HTTP protocol does not place any a priori limit on the length of a URI."

For the datatype, I am unsure of which would be more memory efficient, even after reading this doc: http://dev.mysql.com/doc/refman/5.0/en/string-type-overview.html

The maximum storage size of both VARCHAR and TEXT in versions of mySQL >= 5.0.3 is 65,535 bytes. It seems that it would not matter either way, but I suspect that one method may be preferred over another as a matter of best practice. I'm quite curious about this.

I think everyone can agree that URIs over 255 characters are common enough that they should be supported. And if there is a limit, it shouldn't be WordPress that is enforcing it.

I should also note that I am not an expert, and that this is my first bug report :)

#3 @Ipstenu
8 years ago

I'm going to chime in because this is getting more and more common. VARCHAR(1024) seems like a reasonable change in 2011. We all know shorter is better, but sometimes you get a long URL, and having to rely on manual edits OR a URL shortener seems a bit much.

#4 @SergeyBiryukov
8 years ago

  • Keywords has-patch added

#5 @SergeyBiryukov
6 years ago

  • Keywords needs-patch added; has-patch removed
  • Milestone changed from Future Release to 3.7

Moving for review along with #17296. Needs a new patch along the lines of ticket:17296:17296.2.patch.

#6 @vinod dalvi
6 years ago

  • Cc mozillavvd@… added
  • Keywords has-patch added; needs-patch removed

refresh of original patch along a new patch for #17296.

Last edited 6 years ago by SergeyBiryukov (previous) (diff)

@vinod dalvi
6 years ago

refresh of original patch along a new patch for #17296.

#7 @SergeyBiryukov
6 years ago

I meant adding maxlength="255" where necessary (per ocean90's comment), not changing the database field.

We could probably extend link_url though if that's feasible, per comment:2 and comment:3.

@vinod dalvi
6 years ago

New patch along the lines of ticket:17296:17296.2.patch

@johnbillion
6 years ago

#8 @johnbillion
6 years ago

  • Keywords commit added; 2nd-opinion dev-feedback removed

Refreshed Vinod Dalvi's patch and removed the unwanted schema change. Good to go. Related: #17296.

#9 @nacin
6 years ago

  • Owner set to nacin
  • Resolution set to fixed
  • Status changed from new to closed

In 25670:

Links manager: Restrict field length based on DB schema.

props solarissmoke, vinod-dalvi.
fixes #17296, #12264.

Note: See TracTickets for help on using tickets.