Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMI: Convert contact module variables to configuration system #217

Closed
jenlampton opened this issue Apr 5, 2014 · 9 comments
Closed

CMI: Convert contact module variables to configuration system #217

jenlampton opened this issue Apr 5, 2014 · 9 comments

Comments

@jenlampton
Copy link
Member

This issue focuses on converting the following variables to configuration:

contact_default_status, contact_threshold_limit, contact_threshold_window

d.o issue

@behindthepage
Copy link

I will do this. I have had a close association with the contact module since 4.7 as I have a contrib module on drupal,org called contact_forms

Regards
Geoff

@quicksketch
Copy link
Member

Great @behindthepage! I'll be attending DrupalCamp Mexico the next couple of days, but if you need help give me a shout. :)

@behindthepage
Copy link

I assume we will keep the names the same for ease of upgrading i.e.

{
  "_config_name": "contact.settings",
  "contact_default_status": 1,
  "contact_threshold_limit": 5,
  "contact_threshold_window": 3600
}

Are you planning to have hook_update_1000() to migrate data from D7,D6 etc?
Regards
Geoff

@quicksketch
Copy link
Member

Are you planning to have hook_update_1000() to migrate data from D7,D6 etc?

Yes, that's the plan, but for now, 8xxx upgrades are in place, so continuing that paradigm until we switch to 1xxx update functions is expected. :)

@behindthepage
Copy link

Should we delete variables after migrating them?

/**
 * Convert contact module settings to use configuration files.
 */
function contact_update_8000() {
  config_install_default_config('module', 'contact.settings');
  $config = config('contact.settings');
  $config->set('contact_default_status', variable_get('contact_default_status', 1));
  $config->set('contact_threshold_limit', variable_get('contact_threshold_limit', 5));
  $config->set('contact_threshold_window', variable_get('contact_threshold_window', 3600));
  $config->save();
  // delete old variables
  variable_del('contact_default_status');
  variable_del('contact_threshold_limit');
  variable_del('contact_threshold_window');
}

It wasn't done in the system.install

/**
 * Convert performance module settings to use configuration files.
 */
function system_update_8003() {
  config_install_default_config('system', 'system.performance');
  $config = config('system.performance');
  $config->set('cache', variable_get('cache', 0));
  $config->set('cache_lifetime', variable_get('cache_lifetime', '0'));
  $config->set('page_cache_maximum_age', variable_get('page_cache_maximum_age', '0'));
  $config->set('page_compression', variable_get('page_compression', 1));
  $config->set('preprocess_css', variable_get('preprocess_css', 0));
  $config->set('preprocess_js', variable_get('preprocess_js', 0));
  $config->save();
}

Regards
Geoff

@behindthepage
Copy link

Shouldn't config_install_default_config('module', 'contact.settings') be in hook_install not hook_update?

function contact_install() {
  config_install_default_config('module', 'contact.settings');
}  

Regards
Geoff

@quicksketch
Copy link
Member

Should we delete variables after migrating them?

Yep!

Shouldn't config_install_default_config('module', 'contact.settings') be in hook_install not hook_update?

Modules always have their default config installed for them upon install, so there's no need to call it manually. It's similar to how you don't need to call drupal_install_schema() in hook_install() any more either. For an update, we have to call it manually because the module is already considered installed.

@quicksketch
Copy link
Member

I've merged in backdrop/backdrop#201. Thanks @behindthepage!

@quicksketch
Copy link
Member

Followup to convert contact categories as well at #173

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants