Firstly I didn't understand what's the problem after saving a view, I got a non-informative error message:
http://drupal.org/files/PDOException%20-%20Data%20too%20long%20for%20column%20'display_title'.png
OK, I went to "Recent log messages", and I saw this error message:
"PDOException: SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'display_title' at row 1: INSERT INTO {views_display} ......."
OK, in Views views_display table, display_title field's type is varchar(64).
I saw I really wanted to input a title which is more than 64 characters.
But why aren't there any checks BEFORE even trying to upload these long titles to the database? Views should output an error message, saying "Title too long, please type in a shorter title" or sg. like that.
Besides, why isn't this exception handled correctly, not to see a so non-informative error like the one linked above? (OK, maybe this is rather a general Drupal-related question, but I think Views could handle its own exceptions too...)
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | add-maxlength-check-to-view-display-title-field-1807868-4.patch | 597 bytes | nagba |
| PDOException - Data too long for column 'display_title'.png | 11.41 KB | Sk8erPeter |
Comments
Comment #1
Jarek Polok commentedSame problem here, we try to expose aggregator feed (where 'title' limit is 255 chars) in a View ... where it is 64: indeed a len check would be useful ...
Comment #2
geek-merlin@Sk8erPeter: thank you for your bug report.
Your question "why doesn't views check...?" is answered easily: because nobody did fix it yet - it's free software, man!
And you did the first step in the right direction.
I can confirm that the problem is also in current d7 dev.
Next step for anyone (even @Novice) who wants to help is to (maybe goto simplytest.me and) check if the problem is also in drupal8 dev (where views is in core). If yes, set version accordingly, this will strongly speed up the fix!
Comment #3
Dobby commentedBug is not currently in D8. Fields are limited to 128 characters. However they allow you to enter more then give a warning:
It might be a good idea for the maximum length of the input field to match the maximum length of the value but it is functional as it stands.
Edit to clarify: View add form allows entry of more than 128 characters then displays above warning. View edit form appears to limit entry to 128 characters on relevant fields.
Comment #4
nagba commentedwell if the bug doesnt appear in D8, we could just simply add a maxlength check to the display title form element.
Comment #4.0
nagba commentedplural
Comment #5
chris matthews commentedThe 6 year old patch in #4 to views_plugin_display.inc applied cleanly to the latest views 7.x-3.x-dev and if still applicable needs review.
Comment #6
renatog commentedYeah, the patch really applied and it worked well.
Thank you so much, Balazs
Comment #8
renatog commentedMoved to the dev branch
Thank you so much everyone
Comment #9
damienmckenna