Changing the machine name wreaks tremendous low-level havoc that ruins data integrity in the database.

If a view is in use, for instance a view block display placed in a region or a panel pane (if Panels module is installed), then either: 1) forbid the user to change that view's or display's machine name, or 2) allow the user to change the machine name and -- behind the scenes -- have the Views module intelligently integrate with other dependent modules and do a search and replace for the machine name string throughout the database.

Comments

dawehner’s picture

Detecting whether a view is used somewhere else is really hard if not logically impossible.
Also your second suggestion is really hard because actually the other modules should react on that.

My suggestion would be here to warn the user, that renaming the machine_name can cause some problems. What do you think about that?

amfriedman’s picture

A warning is better than nothing, that's for sure! Given the fatal implications of such a rename -- panel panes being obliterated from the live site for instance -- I would highly recommend this is added in. An alert box perhaps, or simply a note beneath the field.

Also, part of what is so tricky about "knowing" where views are being used from other modules is the arbitrary way some modules' configuration data is saved in the database. In Panels in particular, panel/pane config data is simply jammed into a single field as a serialized array. This is problematic on many fronts, the least of which is that it is very difficult for any module to "know" what is in that array and to edit it programmatically without irreversibly screwing something up. This is precisely the reason why data belongs in a proper normalized database, so there is a structured why in which one reads and writes; not the brittleness of a serialized array.

dawehner’s picture

Issue tags: +Novice

Give user advanced tools and they will destroy their sites :)

About the data storage: The main problem is that the schema of panels would have to be dynamic. You can't know at install time what kind of data a certain piece of information want to store. So to be able to do that you would need a lot of really complicated mess ... It's actually also possible to find that information out if you would use just exported objects, so you could use php to find that out, but as i wrote above, that's not trivial.

About the central problem, the data structure wouldn't probably help as well, because you would still not know where references to views are in ... anyway added a tag, let's see who will create a warning on that setting.

swarad07’s picture

Status: Active » Needs review
StatusFileSize
new712 bytes

Have added a warning below the field description. Adding the patch for the same.

Cheers

dawehner’s picture

+++ b/plugins/views_plugin_display.incundefined
@@ -1436,6 +1436,7 @@ class views_plugin_display extends views_plugin {
+		  '#suffix' => t('Warning: Changing the machine name is not recommended. This may result in loss of configurations for some modules.'),

What about append this to the description and use spaces instead of tabs :)

swarad07’s picture

Acknowledged !

I thought it was better to add it separately instead of adding it under description :)

Anyways, my eclipse completely screwed up the spacing. Attaching new patch.

dawehner’s picture

+++ b/plugins/views_plugin_display.incundefined
@@ -1435,7 +1435,7 @@ class views_plugin_display extends views_plugin {
+          '#description' => t('This is machine name of the display. Changing the machine name is not recommended, This may result in loss of configurations for some modules.'),

We are currently in the stable phase of a contrib module, so we shouldn't break translations. What about adding a new t() function?

swarad07’s picture

+++ b/plugins/views_plugin_display.inc
@@ -1435,7 +1435,7 @@ class views_plugin_display extends views_plugin {
+          '#description' => t('This is machine name of the display.') . t(' Changing the machine name is not recommended, This may result in loss of configurations for some modules.'),

Something like this ? I have appended another t() to the existing one for #description.

dawehner’s picture

+++ b/plugins/views_plugin_display.incundefined
@@ -1435,7 +1435,7 @@ class views_plugin_display extends views_plugin {
+          '#description' => t('This is machine name of the display.') . t(' Changing the machine name is not recommended, This may result in loss of configurations for some modules.'),

this should be probably written small.

swarad07’s picture

Silly me :-?

BeachsidePaul’s picture

Issue summary: View changes

After having spent a full day trying to override a view template file (views-view-unformatted.tpl.php) using the view's machine name, which had been changed, I stumbled on this issue. The theme information was suggesting the template be named with the new machine name but, unfortunately, this was not being picked up in the Drupal processing. The template file was being highlighted on the theme info display but it was NOT being used. Using one of the non-machine-name template names that were suggested worked right away of course. I really think that when a change is made to the machine name, the user should, at the very least, be warned of the possible ramifications.

swarad07’s picture

Version: 7.x-3.3 » 7.x-3.x-dev
StatusFileSize
new840 bytes

Re-rolling the patch against latest 7.x-3.x.

chris matthews’s picture

The 3 year old patch in #12 to views_plugin_display.inc applied cleanly to the latest views 7.x-3.x-dev and if still relevant needs to be reviewed.