diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc
index 03009b3..49f0a31 100644
--- a/core/includes/bootstrap.inc
+++ b/core/includes/bootstrap.inc
@@ -2195,15 +2195,15 @@ function drupal_bootstrap($phase = NULL, $new_phase = TRUE) {
*/
function drupal_get_user_timezone() {
global $user;
- $config = config('system.date');
+ $config = config('system.timezone');
- if ($config->get('timezone.user.configurable') && $user->uid && $user->timezone) {
+ if ($config->get('user.configurable') && $user->uid && $user->timezone) {
return $user->timezone;
}
else {
// Ignore PHP strict notice if time zone has not yet been set in the php.ini
// configuration.
- $config_data_default_timezone = $config->get('timezone.default');
+ $config_data_default_timezone = $config->get('default');
return !empty($config_data_default_timezone) ? $config_data_default_timezone : @date_default_timezone_get();
}
}
diff --git a/core/includes/config.inc b/core/includes/config.inc
index 00c7fa6..31365e5 100644
--- a/core/includes/config.inc
+++ b/core/includes/config.inc
@@ -102,7 +102,7 @@ function config_get_storage_names_with_prefix($prefix = '') {
* A configuration object.
*/
function config($name) {
- return drupal_container()->get('config.factory')->get($name)->load();
+ return drupal_container()->get('config.factory')->get($name);
}
/**
@@ -141,11 +141,11 @@ function config_sync_get_changes(StorageInterface $source_storage, StorageInterf
'delete' => array(),
);
- foreach (array_diff_assoc($target_config_data, $source_config_data) as $name => $value) {
+ foreach (array_diff_key($target_config_data, $source_config_data) as $name => $value) {
$config_changes['delete'][] = $value['name'];
}
- foreach (array_diff_assoc($source_config_data, $target_config_data) as $name => $value) {
+ foreach (array_diff_key($source_config_data, $target_config_data) as $name => $value) {
$config_changes['create'][] = $value['name'];
}
@@ -190,6 +190,8 @@ function config_sync_changes(array $config_changes, StorageInterface $source_sto
}
}
}
+ // Config might have changed, reset the stored config objects.
+ drupal_container()->get('config.factory')->resetConfigs();
}
/**
diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc
index 8e0e29c..ef50d04 100644
--- a/core/includes/install.core.inc
+++ b/core/includes/install.core.inc
@@ -2006,8 +2006,11 @@ function install_configure_form_submit($form, &$form_state) {
->set('mail', $form_state['values']['site_mail'])
->save();
+ config('system.timezone')
+ ->set('default', $form_state['values']['date_default_timezone'])
+ ->save();
+
config('system.date')
- ->set('timezone.default', $form_state['values']['date_default_timezone'])
->set('country.default', $form_state['values']['site_default_country'])
->save();
diff --git a/core/lib/Drupal/Core/Config/Config.php b/core/lib/Drupal/Core/Config/Config.php
index 6fc2a87..c6a320e 100644
--- a/core/lib/Drupal/Core/Config/Config.php
+++ b/core/lib/Drupal/Core/Config/Config.php
@@ -65,6 +65,16 @@ class Config {
protected $eventDispatcher;
/**
+ * Whether the config object has already been loaded.
+ *
+ * Aside from TRUE or FALSE it can be NULL when inside load() to signal the
+ * "being loaded" phase.
+ *
+ * @var bool
+ */
+ protected $isLoaded = FALSE;
+
+ /**
* Constructs a configuration object.
*
* @param string $name
@@ -88,6 +98,8 @@ public function __construct($name, StorageInterface $storage, EventDispatcher $e
* The configuration object.
*/
public function init() {
+ $this->isLoaded = FALSE;
+ $this->overrides = array();
$this->notify('init');
return $this;
}
@@ -120,6 +132,9 @@ public function setName($name) {
* TRUE if this config object does not exist in storage.
*/
public function isNew() {
+ if (!$this->isLoaded) {
+ $this->load();
+ }
return $this->isNew;
}
@@ -151,6 +166,9 @@ public function isNew() {
* The data that was requested.
*/
public function get($key = '') {
+ if (!$this->isLoaded) {
+ $this->load();
+ }
if (!isset($this->overriddenData)) {
$this->setOverriddenData();
}
@@ -179,6 +197,11 @@ public function get($key = '') {
* The configuration object.
*/
public function setData(array $data) {
+ // A load would destroy the data just set (for example on import). Do not
+ // set when inside load().
+ if (isset($this->isLoaded)) {
+ $this->isLoaded = TRUE;
+ }
$this->data = $data;
$this->resetOverriddenData();
return $this;
@@ -243,6 +266,9 @@ protected function resetOverriddenData() {
* The configuration object.
*/
public function set($key, $value) {
+ if (!$this->isLoaded) {
+ $this->load();
+ }
// Type-cast value into a string.
$value = $this->castValue($value);
@@ -309,6 +335,9 @@ public function castValue($value) {
* The configuration object.
*/
public function clear($key) {
+ if (!$this->isLoaded) {
+ $this->load();
+ }
$parts = explode('.', $key);
if (count($parts) == 1) {
unset($this->data[$key]);
@@ -327,6 +356,7 @@ public function clear($key) {
* The configuration object.
*/
public function load() {
+ $this->isLoaded = NULL;
$data = $this->storage->read($this->name);
if ($data === FALSE) {
$this->isNew = TRUE;
@@ -337,6 +367,7 @@ public function load() {
$this->setData($data);
}
$this->notify('load');
+ $this->isLoaded = TRUE;
return $this;
}
@@ -347,6 +378,9 @@ public function load() {
* The configuration object.
*/
public function save() {
+ if (!$this->isLoaded) {
+ $this->load();
+ }
$this->storage->write($this->name, $this->data);
$this->isNew = FALSE;
$this->notify('save');
@@ -412,8 +446,12 @@ protected function notify($config_event_name) {
* The configuration object.
*/
public function merge(array $data_to_merge) {
+ if (!$this->isLoaded) {
+ $this->load();
+ }
// Preserve integer keys so that config keys are not changed.
$this->data = NestedArray::mergeDeepArray(array($this->data, $data_to_merge), TRUE);
+ $this->resetOverriddenData();
return $this;
}
}
diff --git a/core/lib/Drupal/Core/Config/ConfigFactory.php b/core/lib/Drupal/Core/Config/ConfigFactory.php
index ca36ce7..826105a 100644
--- a/core/lib/Drupal/Core/Config/ConfigFactory.php
+++ b/core/lib/Drupal/Core/Config/ConfigFactory.php
@@ -38,6 +38,8 @@ class ConfigFactory {
*/
protected $eventDispatcher;
+ protected $configs = array();
+
/**
* Constructs the Config factory.
*
@@ -64,26 +66,15 @@ public function __construct(StorageInterface $storage, EventDispatcher $event_di
public function get($name) {
global $conf;
- // @todo Caching the instantiated objects per name might cut off a fair
- // amount of CPU time and memory. Only the data within the configuration
- // object changes, so the additional cost of instantiating duplicate
- // objects could possibly be avoided. It is not uncommon for a
- // configuration object to be retrieved many times during a single
- // request; e.g., 'system.performance' alone is retrieved around 10-20
- // times within a single page request. Sub-requests via HttpKernel will
- // most likely only increase these counts.
- // @todo Benchmarks were performed with a script that essentially retained
- // all instantiated configuration objects in memory until script execution
- // ended. A variant of that script called config() within a helper
- // function only, which inherently meant that PHP destroyed all
- // configuration objects after leaving the function. Consequently,
- // benchmark results looked entirely different. Profiling should probably
- // redone under more realistic conditions; e.g., actual HTTP requests.
- // @todo The decrease of CPU time is interesting, since that means that
- // ContainerBuilder involves plenty of function calls (which are known to
- // be slow in PHP).
- $config = new Config($name, $this->storage, $this->eventDispatcher);
- return $config->init();
+ if (isset($this->configs[$name])) {
+ return $this->configs[$name];
+ }
+
+ $this->configs[$name] = new Config($name, $this->storage, $this->eventDispatcher);
+ return $this->configs[$name]->init();
}
+ function resetConfigs() {
+ $this->configs = array();
+ }
}
diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php b/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php
index 6d0a3f4..af37199 100644
--- a/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php
+++ b/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php
@@ -287,9 +287,10 @@ public function save(EntityInterface $entity) {
$id = $entity->getOriginalID();
}
$config = config($prefix . $id);
+ $is_new = $config->isNew();
$config->setName($prefix . $entity->id());
- if (!$config->isNew() && !isset($entity->original)) {
+ if (!$is_new && !isset($entity->original)) {
$this->resetCache(array($id));
$result = $this->load(array($id));
$entity->original = reset($result);
@@ -303,7 +304,7 @@ public function save(EntityInterface $entity) {
$config->set($key, $value);
}
- if (!$config->isNew()) {
+ if (!$is_new) {
$return = SAVED_UPDATED;
$config->save();
$this->postSave($entity, TRUE);
@@ -382,6 +383,11 @@ protected function postSave(EntityInterface $entity, $update) {
if ($update && !empty($entity->original) && $entity->{$this->idKey} !== $entity->original->{$this->idKey}) {
// @todo This should just delete the original config object without going
// through the API, no?
+ // @todo: We try to delete the original here, but because ConfigFactory
+ // still things the new one that has been renamed is the original, we
+ // end up deleting the new config file instead of the old one. Clearing
+ // the cache fixes this, but isn't the correct approach.
+ drupal_container()->get('config.factory')->resetConfigs();
$entity->original->delete();
}
}
diff --git a/core/lib/Drupal/Core/CoreBundle.php b/core/lib/Drupal/Core/CoreBundle.php
index e1147ac..447f730 100644
--- a/core/lib/Drupal/Core/CoreBundle.php
+++ b/core/lib/Drupal/Core/CoreBundle.php
@@ -55,7 +55,8 @@ public function build(ContainerBuilder $container) {
->addMethodCall('addSubscriber', array(new Reference('config.subscriber.globalconf')));
$container->register('config.factory', 'Drupal\Core\Config\ConfigFactory')
->addArgument(new Reference('config.storage'))
- ->addArgument(new Reference('dispatcher'));
+ ->addArgument(new Reference('dispatcher'))
+ ->addTag('persist');
// Register staging configuration storage.
$container
diff --git a/core/lib/Drupal/Core/DrupalKernel.php b/core/lib/Drupal/Core/DrupalKernel.php
index f0621fc..efd35eb 100644
--- a/core/lib/Drupal/Core/DrupalKernel.php
+++ b/core/lib/Drupal/Core/DrupalKernel.php
@@ -259,6 +259,12 @@ protected function getClassName() {
* Initializes the service container.
*/
protected function initializeContainer() {
+ $persist = array();
+ if (isset($this->container) && method_exists($this->container, 'findTaggedServiceIds')) {
+ foreach ($this->container->findTaggedServiceIds('persist') as $id => $tags) {
+ $persist[$id] = $this->container->get($id);
+ }
+ }
$this->container = NULL;
$class = $this->getClassName();
$cache_file = $class . '.php';
@@ -285,6 +291,9 @@ protected function initializeContainer() {
// Second, check if some other request -- for example on another web
// frontend or during the installer -- changed the list of enabled modules.
if (isset($this->container)) {
+ foreach ($persist as $id => $object) {
+ $this->container->set($id, $object);
+ }
// All namespaces must be registered before we attempt to use any service
// from the container.
$container_modules = $this->container->getParameter('container.modules');
@@ -309,6 +318,9 @@ protected function initializeContainer() {
if (!isset($this->container)) {
$this->container = $this->buildContainer();
+ foreach ($persist as $id => $object) {
+ $this->container->set($id, $object);
+ }
if ($this->allowDumping) {
$this->containerNeedsDumping = TRUE;
}
diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigOverrideTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigOverrideTest.php
index 8e83a84..e2ddb59 100644
--- a/core/modules/config/lib/Drupal/config/Tests/ConfigOverrideTest.php
+++ b/core/modules/config/lib/Drupal/config/Tests/ConfigOverrideTest.php
@@ -64,7 +64,7 @@ function testConfOverride() {
$this->assertIdentical($config->get('404'), $expected_original_data['404']);
// Reload the configuration object.
- $config = config('config_test.system');
+ $config->init();
// Verify that it contains the overridden data from $conf.
$this->assertIdentical($config->get('foo'), $conf['config_test.system']['foo']);
@@ -97,7 +97,7 @@ function testConfOverride() {
unset($conf['config_test.system']);
// Reload it and verify that it still contains the original data.
- $config = config('config_test.system');
+ $config->init();
$this->assertIdentical($config->get('foo'), $expected_original_data['foo']);
$this->assertIdentical($config->get('baz'), $expected_original_data['baz']);
$this->assertIdentical($config->get('404'), $expected_original_data['404']);
diff --git a/core/modules/config/lib/Drupal/config/Tests/LocaleConfigOverride.php b/core/modules/config/lib/Drupal/config/Tests/LocaleConfigOverride.php
index adfe0b9..0ae38a3 100644
--- a/core/modules/config/lib/Drupal/config/Tests/LocaleConfigOverride.php
+++ b/core/modules/config/lib/Drupal/config/Tests/LocaleConfigOverride.php
@@ -37,7 +37,7 @@ function testLocaleConfigOverride() {
// Spoof multilingual.
$GLOBALS['conf']['language_count'] = 2;
drupal_language_initialize();
- $config = config($name);
+ $config->init();
$this->assertIdentical($config->get('foo'), 'en bar');
}
}
diff --git a/core/modules/openid/lib/Drupal/openid/Tests/OpenIDRegistrationTest.php b/core/modules/openid/lib/Drupal/openid/Tests/OpenIDRegistrationTest.php
index d8847c1..99a1536 100644
--- a/core/modules/openid/lib/Drupal/openid/Tests/OpenIDRegistrationTest.php
+++ b/core/modules/openid/lib/Drupal/openid/Tests/OpenIDRegistrationTest.php
@@ -42,9 +42,9 @@ function setUp() {
function testRegisterUserWithEmailVerification() {
config('user.settings')->set('verify_mail', TRUE)->save();
- config('system.date')
- ->set('timezone.user.configurable', 1)
- ->set('timezone.default', 'Europe/Brussels')
+ config('system.timezone')
+ ->set('user.configurable', 1)
+ ->set('default', 'Europe/Brussels')
->save();
// Tell openid_test.module to respond with these SREG fields.
@@ -101,9 +101,9 @@ function testRegisterUserWithEmailVerification() {
function testRegisterUserWithoutEmailVerification() {
config('user.settings')->set('verify_mail', FALSE)->save();
- config('system.date')
- ->set('timezone.user.configurable', 1)
- ->set('timezone.default', 'Europe/Brussels')
+ config('system.timezone')
+ ->set('user.configurable', 1)
+ ->set('default', 'Europe/Brussels')
->save();
// Tell openid_test.module to respond with these SREG fields.
@@ -143,9 +143,9 @@ function testRegisterUserWithoutEmailVerification() {
* information (a username that is already taken, and no e-mail address).
*/
function testRegisterUserWithInvalidSreg() {
- config('system.date')
- ->set('timezone.user.configurable', 1)
- ->set('timezone.default', 'Europe/Brussels')
+ config('system.timezone')
+ ->set('user.configurable', 1)
+ ->set('default', 'Europe/Brussels')
->save();
// Tell openid_test.module to respond with these SREG fields.
@@ -233,8 +233,8 @@ function testRegisterUserWithoutSreg() {
*/
function testRegisterUserWithAXButNoSREG() {
config('user.settings')->set('verify_mail', FALSE)->save();
- config('system.date')
- ->set('timezone.default', 'Europe/Brussels')
+ config('system.timezone')
+ ->set('default', 'Europe/Brussels')
->save();
// Tell openid_test.module to respond with these AX fields.
diff --git a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
index 001e521..cb62f0c 100644
--- a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
+++ b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
@@ -1227,6 +1227,7 @@ protected function drupalPost($path, $edit, $submit, array $options = array(), a
$out = $this->curlExec(array(CURLOPT_URL => $action, CURLOPT_POST => TRUE, CURLOPT_POSTFIELDS => $post, CURLOPT_HTTPHEADER => $headers));
// Ensure that any changes to variables in the other thread are picked up.
$this->refreshVariables();
+ drupal_container()->get('config.factory')->resetConfigs();
// Replace original page output with new output from redirected page(s).
if ($new = $this->checkForMetaRefresh()) {
diff --git a/core/modules/system/config/system.date.yml b/core/modules/system/config/system.date.yml
index ab21797..82a22bc 100644
--- a/core/modules/system/config/system.date.yml
+++ b/core/modules/system/config/system.date.yml
@@ -1,12 +1,6 @@
first_day: '0'
country:
default: ''
-timezone:
- default: ''
- user:
- configurable: '1'
- default: '0'
- warn: '0'
formats:
long:
name: 'Default Long Date'
diff --git a/core/modules/system/config/system.timezone.yml b/core/modules/system/config/system.timezone.yml
new file mode 100644
index 0000000..b0d33a1
--- /dev/null
+++ b/core/modules/system/config/system.timezone.yml
@@ -0,0 +1,5 @@
+default: ''
+user:
+ configurable: '1'
+ default: '0'
+ warn: '0'
diff --git a/core/modules/system/lib/Drupal/system/Tests/Common/FormatDateTest.php b/core/modules/system/lib/Drupal/system/Tests/Common/FormatDateTest.php
index e89a302..1edc236 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Common/FormatDateTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Common/FormatDateTest.php
@@ -36,8 +36,10 @@ public static function getInfo() {
function setUp() {
parent::setUp('language');
+ config('system.timezone')
+ ->set('user.configurable', 1)
+ ->save();
config('system.date')
- ->set('timezone.user.configurable', 1)
->set('formats.long.pattern.php', 'l, j. F Y - G:i')
->set('formats.medium.pattern.php', 'j. F Y - G:i')
->set('formats.short.pattern.php', 'Y M j - g:ia')
diff --git a/core/modules/system/lib/Drupal/system/Tests/Datetime/DrupalDateTimeTest.php b/core/modules/system/lib/Drupal/system/Tests/Datetime/DrupalDateTimeTest.php
index 5539a61..698ea1a 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Datetime/DrupalDateTimeTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Datetime/DrupalDateTimeTest.php
@@ -48,8 +48,10 @@ public function testDateTimezone() {
$date_string = '2007-01-31 21:00:00';
// Make sure no site timezone has been set.
- config('system.date')->set('timezone.default', NULL)->save();
- config('system.date')->set('timezone.user.configurable', 0)->save();
+ config('system.timezone')
+ ->set('user.configurable', 0)
+ ->set('default', NULL)
+ ->save();
// Detect the system timezone.
$system_timezone = date_default_timezone_get();
@@ -66,7 +68,7 @@ public function testDateTimezone() {
$this->assertTrue($timezone == 'America/Yellowknife', 'DrupalDateTime uses the specified timezone if provided.');
// Set a site timezone.
- config('system.date')->set('timezone.default', 'Europe/Warsaw')->save();
+ config('system.timezone')->set('default', 'Europe/Warsaw')->save();
// Create a date object with an unspecified timezone, which should
// end up using the site timezone.
@@ -75,7 +77,7 @@ public function testDateTimezone() {
$this->assertTrue($timezone == 'Europe/Warsaw', 'DrupalDateTime uses the site timezone if provided.');
// Create user.
- config('system.date')->set('timezone.user.configurable', 1)->save();
+ config('system.timezone')->set('user.configurable', 1)->save();
$test_user = $this->drupalCreateUser(array());
$this->drupalLogin($test_user);
diff --git a/core/modules/system/lib/Drupal/system/Tests/System/DateTimeTest.php b/core/modules/system/lib/Drupal/system/Tests/System/DateTimeTest.php
index 2c6571a..7a0f5c0 100644
--- a/core/modules/system/lib/Drupal/system/Tests/System/DateTimeTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/System/DateTimeTest.php
@@ -43,9 +43,11 @@ function setUp() {
*/
function testTimeZoneHandling() {
// Setup date/time settings for Honolulu time.
- $config = config('system.date')
- ->set('timezone.default', 'Pacific/Honolulu')
- ->set('timezone.user.configurable', 0)
+ $config = config('system.timezone')
+ ->set('default', 'Pacific/Honolulu')
+ ->set('user.configurable', 0)
+ ->save();
+ config('system.date')
->set('formats.medium.pattern.php', 'Y-m-d H:i:s O')
->save();
@@ -62,7 +64,7 @@ function testTimeZoneHandling() {
$this->assertText('2007-07-31 21:00:00 -1000', 'Date should be identical, with GMT offset of -10 hours.');
// Set time zone to Los Angeles time.
- $config->set('timezone.default', 'America/Los_Angeles')->save();
+ $config->set('default', 'America/Los_Angeles')->save();
// Confirm date format and time zone.
$this->drupalGet("node/$node1->nid");
diff --git a/core/modules/system/system.admin.inc b/core/modules/system/system.admin.inc
index b8cae7a..826a2f1 100644
--- a/core/modules/system/system.admin.inc
+++ b/core/modules/system/system.admin.inc
@@ -1866,7 +1866,7 @@ function system_rss_feeds_settings_submit($form, &$form_state) {
*/
function system_regional_settings($form, &$form_state) {
$countries = country_get_list();
- $system_date = config('system.date');
+ $system_timezone = config('system.timezone');
$system_date = config('system.date');
// Date settings:
@@ -1898,16 +1898,14 @@ function system_regional_settings($form, &$form_state) {
'#title' => t('Time zones'),
);
- $date_default_timezone = $system_date->get('timezone.default');
- $date_default_timezone = $system_date->get('timezone.default');
$form['timezone']['date_default_timezone'] = array(
'#type' => 'select',
'#title' => t('Default time zone'),
- '#default_value' => isset($date_default_timezone) ? $date_default_timezone : date_default_timezone_get(),
+ '#default_value' => $system_timezone->get('default') ?: date_default_timezone_get(),
'#options' => $zones,
);
- $configurable_timezones = $system_date->get('timezone.user.configurable');
+ $configurable_timezones = $system_timezone->get('user.configurable');
$form['timezone']['configurable_timezones'] = array(
'#type' => 'checkbox',
'#title' => t('Users may set their own time zone.'),
@@ -1927,14 +1925,14 @@ function system_regional_settings($form, &$form_state) {
$form['timezone']['configurable_timezones_wrapper']['empty_timezone_message'] = array(
'#type' => 'checkbox',
'#title' => t('Remind users at login if their time zone is not set.'),
- '#default_value' => $system_date->get('timezone.user.warn'),
+ '#default_value' => $system_timezone->get('user.warn'),
'#description' => t('Only applied if users may set their own time zone.')
);
$form['timezone']['configurable_timezones_wrapper']['user_default_timezone'] = array(
'#type' => 'radios',
'#title' => t('Time zone for new users'),
- '#default_value' => $system_date->get('timezone.user.default'),
+ '#default_value' => $system_timezone->get('user.default'),
'#options' => array(
DRUPAL_USER_TIMEZONE_DEFAULT => t('Default time zone.'),
DRUPAL_USER_TIMEZONE_EMPTY => t('Empty time zone.'),
@@ -1956,10 +1954,12 @@ function system_regional_settings_submit($form, &$form_state) {
config('system.date')
->set('country.default', $form_state['values']['site_default_country'])
->set('first_day', $form_state['values']['date_first_day'])
- ->set('timezone.default', $form_state['values']['date_default_timezone'])
- ->set('timezone.user.configurable', $form_state['values']['configurable_timezones'])
- ->set('timezone.user.warn', $form_state['values']['empty_timezone_message'])
- ->set('timezone.user.default', $form_state['values']['user_default_timezone'])
+ ->save();
+ config('system.timezone')
+ ->set('default', $form_state['values']['date_default_timezone'])
+ ->set('user.configurable', $form_state['values']['configurable_timezones'])
+ ->set('user.warn', $form_state['values']['empty_timezone_message'])
+ ->set('user.default', $form_state['values']['user_default_timezone'])
->save();
}
diff --git a/core/modules/system/system.install b/core/modules/system/system.install
index be3a6d8..59d9508 100644
--- a/core/modules/system/system.install
+++ b/core/modules/system/system.install
@@ -2286,9 +2286,12 @@ function system_update_8038() {
'site_default_country' => 'country.default',
'date_first_day' => 'first_day',
'date_default_timezone' => 'timezone.default',
- 'configurable_timezones' => 'timezone.user.configurable',
- 'empty_timezone_message' => 'timezone.user.warn',
- 'user_default_timezone' => 'timezone.user.default',
+ ));
+ update_variables_to_config('system.timezone', array(
+ 'date_default_timezone' => 'default',
+ 'configurable_timezones' => 'user.configurable',
+ 'empty_timezone_message' => 'user.warn',
+ 'user_default_timezone' => 'user.default',
));
}
diff --git a/core/modules/system/system.module b/core/modules/system/system.module
index 26fee90..a1d919a 100644
--- a/core/modules/system/system.module
+++ b/core/modules/system/system.module
@@ -2403,7 +2403,7 @@ function system_custom_theme() {
* Implements hook_form_FORM_ID_alter().
*/
function system_form_user_profile_form_alter(&$form, &$form_state) {
- if (config('system.date')->get('timezone.user.configurable')) {
+ if (config('system.timezone')->get('user.configurable')) {
system_user_timezone($form, $form_state);
}
return $form;
@@ -2413,8 +2413,8 @@ function system_form_user_profile_form_alter(&$form, &$form_state) {
* Implements hook_form_FORM_ID_alter().
*/
function system_form_user_register_form_alter(&$form, &$form_state) {
- $config = config('system.date');
- if ($config->get('timezone.user.configurable') && $config->get('timezone.user.default') == DRUPAL_USER_TIMEZONE_SELECT) {
+ $config = config('system.timezone');
+ if ($config->get('user.configurable') && $config->get('user.default') == DRUPAL_USER_TIMEZONE_SELECT) {
system_user_timezone($form, $form_state);
return $form;
}
@@ -2424,9 +2424,9 @@ function system_form_user_register_form_alter(&$form, &$form_state) {
* Implements hook_user_presave().
*/
function system_user_presave($account) {
- $config = config('system.date');
- if ($config->get('timezone.user.configurable') && empty($account->timezone) && !$config->get('timezone.user.default')) {
- $account->timezone = $config->get('timezone.default');
+ $config = config('system.timezone');
+ if ($config->get('user.configurable') && empty($account->timezone) && !$config->get('user.default')) {
+ $account->timezone = $config->get('default');
}
}
@@ -2434,9 +2434,9 @@ function system_user_presave($account) {
* Implements hook_user_login().
*/
function system_user_login($edit, $account) {
- $config = config('system.date');
+ $config = config('system.timezone');
// If the user has a NULL time zone, notify them to set a time zone.
- if (!$account->timezone && $config->get('timezone.user.configurable') && $config->get('timezone.user.warn')) {
+ if (!$account->timezone && $config->get('user.configurable') && $config->get('user.warn')) {
drupal_set_message(t('Configure your account time zone setting.', array('@user-edit' => url("user/$account->uid/edit", array('query' => drupal_get_destination(), 'fragment' => 'edit-timezone')))));
}
}
diff --git a/core/modules/user/lib/Drupal/user/Tests/UserRegistrationTest.php b/core/modules/user/lib/Drupal/user/Tests/UserRegistrationTest.php
index 0b96373..30164f0 100644
--- a/core/modules/user/lib/Drupal/user/Tests/UserRegistrationTest.php
+++ b/core/modules/user/lib/Drupal/user/Tests/UserRegistrationTest.php
@@ -157,9 +157,9 @@ function testRegistrationDefaultValues() {
->save();
// Set the default timezone to Brussels.
- $config_system_date = config('system.date')
- ->set('timezone.user.configurable', 1)
- ->set('timezone.default', 'Europe/Brussels')
+ $config_system_timezone = config('system.timezone')
+ ->set('user.configurable', 1)
+ ->set('default', 'Europe/Brussels')
->save();
// Check that the account information options are not displayed
@@ -183,7 +183,7 @@ function testRegistrationDefaultValues() {
$this->assertEqual($new_user->signature, '', 'Correct signature field.');
$this->assertTrue(($new_user->created > REQUEST_TIME - 20 ), 'Correct creation time.');
$this->assertEqual($new_user->status, $config_user_settings->get('register') == USER_REGISTER_VISITORS ? 1 : 0, 'Correct status field.');
- $this->assertEqual($new_user->timezone, $config_system_date->get('timezone.default'), 'Correct time zone field.');
+ $this->assertEqual($new_user->timezone, $config_system_timezone->get('default'), 'Correct time zone field.');
$this->assertEqual($new_user->langcode, language_default()->langcode, 'Correct language field.');
$this->assertEqual($new_user->preferred_langcode, language_default()->langcode, 'Correct preferred language field.');
$this->assertEqual($new_user->init, $mail, 'Correct init field.');
diff --git a/core/modules/user/lib/Drupal/user/Tests/UserTimeZoneTest.php b/core/modules/user/lib/Drupal/user/Tests/UserTimeZoneTest.php
index 575bfc1..8b77915 100644
--- a/core/modules/user/lib/Drupal/user/Tests/UserTimeZoneTest.php
+++ b/core/modules/user/lib/Drupal/user/Tests/UserTimeZoneTest.php
@@ -26,9 +26,11 @@ public static function getInfo() {
*/
function testUserTimeZone() {
// Setup date/time settings for Los Angeles time.
- $config = config('system.date')
- ->set('timezone.user.configurable', 1)
- ->set('timezone.default', 'America/Los_Angeles')
+ config('system.timezone')
+ ->set('user.configurable', 1)
+ ->set('default', 'America/Los_Angeles')
+ ->save();
+ config('system.date')
->set('formats.medium.pattern.php', 'Y-m-d H:i T')
->save();
diff --git a/core/modules/user/user.api.php b/core/modules/user/user.api.php
index 1c68427..88d23a9 100644
--- a/core/modules/user/user.api.php
+++ b/core/modules/user/user.api.php
@@ -305,9 +305,9 @@ function hook_user_update($account) {
* The user object on which the operation was just performed.
*/
function hook_user_login(&$edit, $account) {
- $config = config('system.date');
+ $config = config('system.timezone');
// If the user has a NULL time zone, notify them to set a time zone.
- if (!$account->timezone && $config->get('timezone.user.configurable') && $config->get('timezone.user.warn')) {
+ if (!$account->timezone && $config->get('user.configurable') && $config->get('user.warn')) {
drupal_set_message(t('Configure your account time zone setting.', array('@user-edit' => url("user/$account->uid/edit", array('query' => drupal_get_destination(), 'fragment' => 'edit-timezone')))));
}
}