function system_post_update_convert_empty_country_and_timezone_settings_to_null

Same name and namespace in other branches
  1. 10 core/modules/system/system.post_update.php \system_post_update_convert_empty_country_and_timezone_settings_to_null()

Updates system.date config to NULL for empty country and timezone defaults.

File

core/modules/system/system.post_update.php, line 67

Code

function system_post_update_convert_empty_country_and_timezone_settings_to_null() : void {
  $system_date_settings = \Drupal::configFactory()->getEditable('system.date');
  $changed = FALSE;
  if ($system_date_settings->get('country.default') === '') {
    $system_date_settings->set('country.default', NULL);
    $changed = TRUE;
  }
  if ($system_date_settings->get('timezone.default') === '') {
    $system_date_settings->set('timezone.default', NULL);
    $changed = TRUE;
  }
  if ($changed) {
    $system_date_settings->save();
  }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.