diff --git a/php/src/Data/ConfigurationManager.php b/php/src/Data/ConfigurationManager.php index 19b0a7bb..25263b50 100644 --- a/php/src/Data/ConfigurationManager.php +++ b/php/src/Data/ConfigurationManager.php @@ -259,7 +259,7 @@ class ConfigurationManager } public bool $collaboraSeccompDisabled { - get => booleanize($this->GetEnvironmentalVariableOrConfig('COLLABORA_SECCOMP_DISABLED', 'collabora_seccomp_disabled', '')); + get => $this->booleanize($this->GetEnvironmentalVariableOrConfig('COLLABORA_SECCOMP_DISABLED', 'collabora_seccomp_disabled', '')); set { $this->set('collabora_seccomp_disabled', $value); } } @@ -269,22 +269,22 @@ class ConfigurationManager } public bool $disableBackupSection { - get => booleanize($this->GetEnvironmentalVariableOrConfig('AIO_DISABLE_BACKUP_SECTION', 'disable_backup_section', '')); + get => $this->booleanize($this->GetEnvironmentalVariableOrConfig('AIO_DISABLE_BACKUP_SECTION', 'disable_backup_section', '')); set { $this->set('disable_backup_section', $value); } } public bool $nextcloudEnableDriDevice{ - get => booleanize($this->GetEnvironmentalVariableOrConfig('NEXTCLOUD_ENABLE_DRI_DEVICE', 'nextcloud_enable_dri_device', '')); + get => $this->booleanize($this->GetEnvironmentalVariableOrConfig('NEXTCLOUD_ENABLE_DRI_DEVICE', 'nextcloud_enable_dri_device', '')); set { $this->set('nextcloud_enable_dri_device', $value); } } public bool $enableNvidiaGpu { - get => booleanize($this->GetEnvironmentalVariableOrConfig('NEXTCLOUD_ENABLE_NVIDIA_GPU', 'enable_nvidia_gpu', '')); + get => $this->booleanize($this->GetEnvironmentalVariableOrConfig('NEXTCLOUD_ENABLE_NVIDIA_GPU', 'enable_nvidia_gpu', '')); set { $this->set('enable_nvidia_gpu', $value); } } public bool $nextcloudKeepDisabledApps { - get => booleanize($this->GetEnvironmentalVariableOrConfig('NEXTCLOUD_KEEP_DISABLED_APPS', 'nextcloud_keep_disabled_apps', '')); + get => $this->booleanize($this->GetEnvironmentalVariableOrConfig('NEXTCLOUD_KEEP_DISABLED_APPS', 'nextcloud_keep_disabled_apps', '')); set { $this->set('nextcloud_keep_disabled_apps', $value); } } @@ -934,6 +934,12 @@ class ConfigurationManager } private function camelize(string $input, string $delimiter = '_') : string { + if ($input === '') { + throw new InvalidSettingConfigurationException('input cannot be empty!'); + } + if ($delimiter === '') { + $delimiter = '_'; + } return lcfirst(implode("", array_map('ucfirst', explode($delimiter, strtolower($input))))); } @@ -948,17 +954,17 @@ class ConfigurationManager error_log("Invalid input: '$variable' is not a string or does not contain an equal sign ('=')"); continue; } - $keyWithValue = $confManager->replaceEnvPlaceholders($variable); + $keyWithValue = $this->replaceEnvPlaceholders($variable); // Pad the result with nulls so psalm is happy (and we don't risk to run into warnings in case // the check for an equal sign from above gets changed). [$key, $value] = explode('=', $keyWithValue, 2) + [null, null]; $key = $this->camelize($key); if ($value === null) { error_log("Invalid input: '$keyWithValue' has no value after the equal sign"); - } else if (!property_exists($confManager, $key)) { + } else if (!property_exists($this, $key)) { error_log("Error: '$key' is not a valid configuration key (in '$keyWithValue')"); } else { - $confManager->$key = $value; + $this->$key = $value; } } $this->commitTransaction(); @@ -1030,7 +1036,7 @@ class ConfigurationManager 'NEXTCLOUD_STARTUP_APPS' => $this->GetNextcloudStartupApps(), 'NEXTCLOUD_ADDITIONAL_APKS' => $this->nextcloudAdditionalApks, 'NEXTCLOUD_ADDITIONAL_PHP_EXTENSIONS' => $this->nextcloudAdditionalPhpExtensions, - 'INSTALL_LATEST_MAJOR' => $this->installLatestMajor, + 'INSTALL_LATEST_MAJOR' => $this->installLatestMajor ? 'yes' : '', 'REMOVE_DISABLED_APPS' => $this->nextcloudKeepDisabledApps ? '' : 'yes', // Allow to get local ip-address of database container which allows to talk to it even in host mode (the container that requires this needs to be started first then) 'AIO_DATABASE_HOST' => gethostbyname('nextcloud-aio-database'),