Some applications may have the need to have urls longer than 255 characters (although it's not a good idea).
If we configure an url field processed by xmlsitemap longer than 255 characters, on the form submit an SQL error is raised, breaking the submit flow.

Though long urls are not a good practice, could we rise the varchar column definition to something like varchar(1024)?
In any case I think the SQL error should be managed to at least not crash the admin.

Issue fork xmlsitemap-1431326

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Anonymous’s picture

Version: 7.x-2.0-beta3 » 7.x-2.x-dev
Category: bug » feature

Based on what I've researched WRT this feature request I'm going to suggest that it be a text field instead of varchar. I found reference that IE 8 has a max of 4096 and I found reference to FF with a max of 2 GB.

czigor’s picture

Version: 7.x-2.x-dev » 2.x-dev
Issue summary: View changes

czigor’s picture

Status: Active » Needs review
czigor’s picture

Test failures are unrelated.

pfrenssen’s picture

This is interesting and yes I agree 255 characters will not be enough for all possible use cases.

I found a discussion about URL lengths on Stack Overflow: https://stackoverflow.com/questions/417142/what-is-the-maximum-length-of...

In short, it highly depends on the use case. In general there is some consensus in this discussion on using 2048 characters as a limit, but that's possibly outdated because this seems to have been mainly a limit of Internet Explorer. Some clients apparently can handle URLs up to 2GB, but that would be a tad excessive.

dave reid’s picture

What does core's path module allow as the maxlength for aliases?

czigor’s picture

From \Drupal\Core\Field\Plugin\Field\FieldType\UriItem:

URIs are not length limited by RFC 2616, but we need to provide a sensible default. There is a de-facto limit of 2000 characters in browsers and other implementors, so we go with 2048.

poker10’s picture

Status: Needs review » Needs work

Thanks for working on this.

Path aliases seems to be varchar(256), but yes, URIs (and also menu URLs) seems to be varchar(2048). Can we use the same number as core then?

Also I think the xmlsitemap_update_8004() is not correct for 2.x branch, which is compatible with D10 and D11. As per https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Extension... , we should probably use something like xmlsitemap_update_10201(). Thanks!

poker10’s picture

Also to confirm: the two failures on Drupal core 11.3.x are unrelated to the patch (needs to be fixed in a separate issue). On 10.6.x pipeline is green.