Skip to content

Commit

Permalink
Merge pull request #31602 from nextcloud/fix/user_ldap-fix-last-chang…
Browse files Browse the repository at this point in the history
…e-updates

Do not update _lastChanged on auto-detected attributes
  • Loading branch information
PVince81 authored Mar 31, 2022
2 parents eea05b0 + 9fc00fd commit d4c558a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 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
11 changes: 7 additions & 4 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 Expand Up @@ -257,6 +256,7 @@ public function readConfiguration(): void {
*/
public function saveConfiguration(): void {
$cta = array_flip($this->getConfigTranslationArray());
$changed = false;
foreach ($this->unsavedChanges as $key) {
$value = $this->config[$key];
switch ($key) {
Expand Down Expand Up @@ -286,9 +286,12 @@ public function saveConfiguration(): void {
if (is_null($value)) {
$value = '';
}
$changed = true;
$this->saveValue($cta[$key], $value);
}
$this->saveValue('_lastChange', (string)time());
if ($changed) {
$this->saveValue('_lastChange', (string)time());
}
$this->unsavedChanges = [];
}

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 d4c558a

Please sign in to comment.