diff --git a/application/controllers/AccountController.php b/application/controllers/AccountController.php index 9852e1111..f172cfeca 100644 --- a/application/controllers/AccountController.php +++ b/application/controllers/AccountController.php @@ -69,7 +69,7 @@ class AccountController extends Controller $form = new PreferenceForm(); $form->setPreferences($user->getPreferences()); - if ($config->get('config_backend', 'db') !== 'none' && isset($config->config_resource)) { + if (isset($config->config_resource)) { $form->setStore(PreferencesStore::create(new ConfigObject(array( 'resource' => $config->config_resource )), $user)); diff --git a/application/forms/Config/GeneralConfigForm.php b/application/forms/Config/GeneralConfigForm.php index 18d379094..5f15512a5 100644 --- a/application/forms/Config/GeneralConfigForm.php +++ b/application/forms/Config/GeneralConfigForm.php @@ -37,13 +37,4 @@ class GeneralConfigForm extends ConfigForm $this->addSubForm($themingConfigForm->create($formData)); $this->addSubForm($domainConfigForm->create($formData)); } - - public function onRequest() - { - parent::onRequest(); - - if ($this->config->get('global', 'config_backend') === 'ini') { - $this->warning('The preferences backend of type INI is deprecated and will be removed with version 2.11'); - } - } } diff --git a/library/Icinga/Authentication/Auth.php b/library/Icinga/Authentication/Auth.php index 45d815bd9..f358eac37 100644 --- a/library/Icinga/Authentication/Auth.php +++ b/library/Icinga/Authentication/Auth.php @@ -376,25 +376,21 @@ class Auth $config = new Config(); } - if ($config->get('global', 'config_backend', 'db') !== 'none') { - $preferencesConfig = new ConfigObject([ - 'resource' => $config->get('global', 'config_resource') - ]); + $preferencesConfig = new ConfigObject([ + 'resource' => $config->get('global', 'config_resource') + ]); - try { - $preferencesStore = PreferencesStore::create($preferencesConfig, $user); - $preferences = new Preferences($preferencesStore->load()); - } catch (Exception $e) { - Logger::error( - new IcingaException( - 'Cannot load preferences for user "%s". An exception was thrown: %s', - $user->getUsername(), - $e - ) - ); - $preferences = new Preferences(); - } - } else { + try { + $preferencesStore = PreferencesStore::create($preferencesConfig, $user); + $preferences = new Preferences($preferencesStore->load()); + } catch (Exception $e) { + Logger::error( + new IcingaException( + 'Cannot load preferences for user "%s". An exception was thrown: %s', + $user->getUsername(), + $e + ) + ); $preferences = new Preferences(); } diff --git a/modules/migrate/library/Migrate/Config/UserDomainMigration.php b/modules/migrate/library/Migrate/Config/UserDomainMigration.php index 1c3f6e181..855a0abdb 100644 --- a/modules/migrate/library/Migrate/Config/UserDomainMigration.php +++ b/modules/migrate/library/Migrate/Config/UserDomainMigration.php @@ -178,80 +178,51 @@ class UserDomainMigration { $config = Config::app(); - $type = $config->get('global', 'config_backend', 'ini'); + $resourceConfig = ResourceFactory::getResourceConfig($config->get('global', 'config_resource')); + if ($resourceConfig->db === 'mysql') { + $resourceConfig->charset = 'utf8mb4'; + } - switch ($type) { - case 'ini': - $directory = Config::resolvePath('preferences'); + /** @var DbConnection $conn */ + $conn = ResourceFactory::createResource($resourceConfig); - $migration = array(); + $query = $conn + ->select() + ->from('icingaweb_user_preference', array('username')) + ->group('username'); - if (DirectoryIterator::isReadable($directory)) { - foreach (new DirectoryIterator($directory) as $username => $path) { - $user = new User($username); + if ($this->map !== null) { + $query->applyFilter(Filter::matchAny(Filter::where('username', array_keys($this->map)))); + } - if (! $this->mustMigrate($user)) { - continue; - } + $users = $query->fetchColumn(); - $migrated = $this->migrateUser($user); + $migration = array(); - $migration[$path] = dirname($path) . '/' . $migrated->getUsername(); - } + foreach ($users as $username) { + $user = new User($username); - foreach ($migration as $from => $to) { - rename($from, $to); - } - } + if (! $this->mustMigrate($user)) { + continue; + } - break; - case 'db': - $resourceConfig = ResourceFactory::getResourceConfig($config->get('global', 'config_resource')); - if ($resourceConfig->db === 'mysql') { - $resourceConfig->charset = 'utf8mb4'; - } + $migrated = $this->migrateUser($user); - /** @var DbConnection $conn */ - $conn = ResourceFactory::createResource($resourceConfig); + $migration[$username] = $migrated->getUsername(); + } - $query = $conn - ->select() - ->from('icingaweb_user_preference', array('username')) - ->group('username'); + if (! empty($migration)) { + $conn->getDbAdapter()->beginTransaction(); - if ($this->map !== null) { - $query->applyFilter(Filter::matchAny(Filter::where('username', array_keys($this->map)))); - } + foreach ($migration as $originalUsername => $username) { + $conn->update( + 'icingaweb_user_preference', + array('username' => $username), + Filter::where('username', $originalUsername) + ); + } - $users = $query->fetchColumn(); - - $migration = array(); - - foreach ($users as $username) { - $user = new User($username); - - if (! $this->mustMigrate($user)) { - continue; - } - - $migrated = $this->migrateUser($user); - - $migration[$username] = $migrated->getUsername(); - } - - if (! empty($migration)) { - $conn->getDbAdapter()->beginTransaction(); - - foreach ($migration as $originalUsername => $username) { - $conn->update( - 'icingaweb_user_preference', - array('username' => $username), - Filter::where('username', $originalUsername) - ); - } - - $conn->getDbAdapter()->commit(); - } + $conn->getDbAdapter()->commit(); } } diff --git a/modules/setup/library/Setup/Steps/GeneralConfigStep.php b/modules/setup/library/Setup/Steps/GeneralConfigStep.php index f15ba6e52..2c928f63b 100644 --- a/modules/setup/library/Setup/Steps/GeneralConfigStep.php +++ b/modules/setup/library/Setup/Steps/GeneralConfigStep.php @@ -28,9 +28,7 @@ class GeneralConfigStep extends Step $config[$section][$property] = $value; } - if ($config['global']['config_backend'] === 'db') { - $config['global']['config_resource'] = $this->data['resourceName']; - } + $config['global']['config_resource'] = $this->data['resourceName']; try { Config::fromArray($config) @@ -57,12 +55,7 @@ class GeneralConfigStep extends Step ? t('An exception\'s stacktrace is shown to every user by default.') : t('An exception\'s stacktrace is hidden from every user by default.') ) . '' - . '
  • ' . sprintf( - $this->data['generalConfig']['global_config_backend'] === 'ini' ? sprintf( - t('Preferences will be stored per user account in INI files at: %s'), - Config::resolvePath('preferences') - ) : t('Preferences will be stored using a database.') - ) . '
  • ' + . '
  • ' . t('Preferences will be stored using a database.') . '
  • ' . ''; $type = $this->data['generalConfig']['logging_log'];