Skip to content

Commit

Permalink
Avoid updating _lastChange when nothing is changed in the configuration
Browse files Browse the repository at this point in the history
Had to set at least one var when creating an empty configuration in
 order to save the default values.

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
  • Loading branch information
come-nc committed Mar 31, 2022
1 parent bd9c4fb commit 9fc00fd
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions apps/user_ldap/lib/Command/CreateEmptyConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ protected function configure() {
protected function execute(InputInterface $input, OutputInterface $output): int {
$configPrefix = $this->helper->getNextServerConfigurationPrefix();
$configHolder = new Configuration($configPrefix);
$configHolder->ldapConfigurationActive = false;
$configHolder->saveConfiguration();

$prose = '';
Expand Down
5 changes: 2 additions & 3 deletions apps/user_ldap/lib/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,9 @@ class Configuration {
*/
protected $configRead = false;
/**
* @var string[] pre-filled with one reference key so that at least one entry is written on save request and
* the config ID is registered
* @var string[]
*/
protected $unsavedChanges = ['ldapConfigurationActive' => 'ldapConfigurationActive'];
protected array $unsavedChanges = [];

/**
* @var array<string, mixed> settings
Expand Down
1 change: 1 addition & 0 deletions apps/user_ldap/lib/Controller/ConfigAPIController.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ public function create() {
try {
$configPrefix = $this->ldapHelper->getNextServerConfigurationPrefix();
$configHolder = new Configuration($configPrefix);
$configHolder->ldapConfigurationActive = false;
$configHolder->saveConfiguration();
} catch (\Exception $e) {
$this->logger->logException($e);
Expand Down

0 comments on commit 9fc00fd

Please sign in to comment.