I've added some basic backwards compatibility for the users that may upgrade to version 2. The idea is to support the old variables but help transitioning to the new variable names (which are structurally different).
To do so I've mapped the old environment_indicator_enabled
, environment_indicator_text
, environment_indicator_color
to the new names for the environment that is set through settings.php (called overritten_environment). Additionally if the users have permissions to see the overritten_environment they will be given a warning to change the settings.php variable names (and add the missing ones). In the status report there will be an error if there are old variable names while using version 2.
Can you help testing this? I'm not sure I'm covering all use cases or if you agree with the method I just described.
Comment | File | Size | Author |
---|---|---|---|
#13 | Interdiff to comment 10 | 1.8 KB | Stevel |
#13 | 1993018-update-old-config-13.patch | 3.71 KB | Stevel |
#10 | 1993018-update-old-config-10.patch | 3.54 KB | Stevel |
#9 | 1993018-update-old-config.patch | 4.49 KB | Stevel |
#5 | 1993018-upgrade-path.patch | 4 KB | Stevel |
Comments
Comment #1
mrfelton CreditAttribution: mrfelton commentedWe at least need an upgrade path from 7.x to 2.x. 2.x introduces a database table, but there is no hopdate hook to create it.
Comment #2
e0ipsoI totally forgot. Now we should be good to go.
(Already pushed to 7.x-2.x-dev, patch is for revision)
Comment #3
Stevel CreditAttribution: Stevel commentedThe old variables still exist, causing it to show up as an overriden indicator, even if there are no variables in settings.php. (it checks for environment_indicator_enabled).
I propose an update function to modify the default configuration with the values from the old variables, and then removing these.
Comment #4
Stevel CreditAttribution: Stevel commentedComment #5
Stevel CreditAttribution: Stevel commentedHere's a patch for the upgrade path. What is does:
Comment #6
mgiffordI couldn't get the last patch to work against the last release.. It rejected one piece of it, but can't see how that would have caused it to fail.. Maybe if I was using the git repo instead.
Upgrades should be easier, but when in doubt, this should also work:
DELETE FROM `variable` WHERE `variable`.`name` = 'environment_indicator_color';
DELETE FROM `variable` WHERE `variable`.`name` = 'environment_indicator_enabled';
DELETE FROM `variable` WHERE `variable`.`name` = 'environment_indicator_margin';
DELETE FROM `variable` WHERE `variable`.`name` = 'environment_indicator_position';
DELETE FROM `variable` WHERE `variable`.`name` = 'environment_indicator_text';
Comment #7
e0ipso@Stevel there are 2 key aspects here.
settings.php
there is no point in deleting them, they won't be removed unless thesettings.php
is edited.settings.php
style. Many people have build on top of thesettings.php
style and we should be supporting them in the 7.x version.This will wipe all variables, not just the old ones.
This conditions will never happen since the settings.php variables are not in the database.
I'm sorry to see that your effort will not be fixed, but if you feel like it I can help you find a nice ticket in the issue queue.
Thanks for your contribution!
Comment #8
Stevel CreditAttribution: Stevel commented@e0ipso:
1. The variables can be defined in settings.php, but also set through the UI in 7.x-1.x (see http://drupalcode.org/project/environment_indicator.git/blob/739e2d71d2f...). When the user has configured the environment indicator via the UI, it would be nice if the behaviour is upgraded.
2. settings.php support is still in place. When an environment in settings.php is configured, this is displayed on the environment indicator overview page.
1. It doesn't remove all variables, only the variables that are no longer used in 7.x-2.x.
2. The variables are in the database if the settings form was saved at least once, which seem is very likely, so the cases will happen for most upgrades from 7.x-1.x. When the form was never saved, the upgrade function does nothing.
If I am misunderstanding something, please explain what is happening then, I'm happy to improve the patch.
Comment #9
Stevel CreditAttribution: Stevel commentedRerolled patch after recent commits.
Comment #10
Stevel CreditAttribution: Stevel commentedI changed the patch to keep support for the old variable names in settings.php, but migrating the old 7.x-1.x variables to the default environment in 7.x-2.x (unless the default environment was already changed)
Comment #11
e0ipsoInstead do something like:
Move this chunk to the top so we don't run the previous code if we are not going to save it.
I'm concerned about a possible data loss in the following scenario: the user edits the default environment, exports it to code in a feature, then runs the DB updates.
Comment #12
Stevel CreditAttribution: Stevel commented1. The reason I didn't use variable_get is that it also uses values from settings.php, while the idea is to migrate the settings stored in the database, leaving those in settings.php alone. I'll update the comment to clarify this.
2. The variable_del statements still have to run to remove the old variables from the database, even if the default environment is already overridden. (otherwise the old variables will still override the ui-configured environment)
Comment #13
Stevel CreditAttribution: Stevel commentedUpdated patch. In addition to the comment changes, it fixes a syntax error (forgotten }) and checks that the default_environment is the one defined in this module before saving.
Comment #14
e0ipsoReviewed and committed (http://drupalcode.org/project/environment_indicator.git/commit/d7a5c5a).
I added some update notification and corrected a typo
result => $result