It seems that a long machine name causes some major issues with views not being saved.

Example 1:
I have a view with a machine name of 'calendar_events_by_production' (37 chars). If I clone this view and name the clone 'calendar events by regular production' then the new machine name of 'calendar_events_by_regular_production' is generated. On immediately attempting to save the view, the following error is shown and the saving fails.

PDOException: SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'name' at row 1: INSERT INTO {views_view} (name, description, tag, base_table, human_name, core) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5); Array ( [:db_insert_placeholder_0] => calendar_events_by_regular_production [:db_insert_placeholder_1] => List of calendar events for a production [:db_insert_placeholder_2] => default [:db_insert_placeholder_3] => node [:db_insert_placeholder_4] => Calendar events by regular production [:db_insert_placeholder_5] => 7 ) in views_db_object->save_row() (line 1945 of /Applications/MAMP/htdocs/hhp2011/sites/all/modules/views/includes/view.inc).

Doing the same steps again but creating a machine name of 'calendar_events_by_produ' (32 chars) saves successfully as expected.

Example 2:
A related issue happens when creating a new view from scratch. I go to /admin/structure/views/add, and name the new view 'Calendar Events by Regular Production'. The matching machine name is shown by the side but none of the buttons at the bottom of the overlay result in an action until the machine name is changed to be 32 chars or less. There is no visual warning that the length is exceeded, so the user has no idea why the buttons don't work.

CommentFileSizeAuthor
#1 1180560-clone-view-validation.patch742 bytesdawehner

Comments

dawehner’s picture

Status: Active » Needs review
StatusFileSize
new742 bytes

Here is a patch for the first part of the issue.

The second one will be pretty tought because that's basically a core bug from my perspective.

merlinofchaos’s picture

Status: Needs review » Reviewed & tested by the community

I think #2 is because Seven, for some reason, does not properly style disabled buttons. That is definitely a core bug.

dawehner’s picture

Status: Reviewed & tested by the community » Fixed

Commited to 7.x-3.x

@martinjbaker do you want to create an core issue and link it here? This would be cool

Anonymous’s picture

Even if they were disabled (and visually so), how would the user know that there was a restriction on the length of machine names? If I go to "Add new view" and immediately press the "Save & exit" or "Continue & edit" buttons then I get these warnings:

* View name field is required.
* Machine-readable name field is required.
* Display "Page" uses a path but the path is undefined.

It isn't possible to get to that stage if the machine name is too long.

Status: Fixed » Closed (fixed)

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