Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
If you go to admin/config/regional/date-time/formats/add and add a date format with more than 100 characters, you get a nice big red error:
PDOException: SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'format' at row 1
The form needs to do some validation to prevent people from entering a format longer than what is allowed in the database.
Also, I think we might really consider a schema change to pump up the size of that database column; 100 seems somewhat arbitrary. (I hit the limit because I was trying to inject some HTML in there so part of the date format could be styled differently from other parts, and when you do that, the characters count up fast.)
Comment | File | Size | Author |
---|---|---|---|
#5 | date_format_maxlength.patch | 870 bytes | mcarbone |
Comments
Comment #1
David_Rothstein CreditAttribution: David_Rothstein commentedI think this qualifies as a "major" bug, although maybe not quite critical. Blank screens with big red error messages are bad.
Comment #2
marcingy CreditAttribution: marcingy commentedChanging to major as per tag.
Comment #3
MustangGB CreditAttribution: MustangGB commentedTag update
Comment #4
dawehnerI guess 255 would be long enough for many people?
Comment #5
mcarbone CreditAttribution: mcarbone commentedIf anything, 100 characters is too long for the date format string -- there are hardly even 30 qualified characters provided by PHP (http://php.net/manual/en/function.date.php) and I'm fairly certain I've never seen a date format string longer than 10 characters. If someone can provide a real world example as to a 100+ character date format string, then I might be persuadable -- but in general it's not good practice in the service of performance to make database fields bigger for no good reason. (The reason stated in the original issue was the desire to use HTML, which isn't the proper use of the date format string.)
All that's really needed here is a FAPI maxlength attribute.
Comment #6
David_Rothstein CreditAttribution: David_Rothstein commented@mcarbone, well, not really - in addition to the characters that get interpreted, PHP deliberately lets you put arbitrary characters in there so you can construct it as a sentence, etc. And 100 is extremely arbitrary when it comes to database column sizes; the performance effect of making it bigger would really be negligible.
However, the patch is good and solves the main part of the bug, so I'm marking it RTBC.
Comment #7
Dries CreditAttribution: Dries commentedCommitted to CVS HEAD. Thanks.