Skip to content

Commit

Permalink
Merge pull request #32070 from nextcloud/backport/31602/stable22
Browse files Browse the repository at this point in the history
[stable22]  Do not update _lastChanged on auto-detected attributes
  • Loading branch information
come-nc authored Apr 25, 2022
2 parents 3153089 + fd61479 commit 49cd75b
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 @@ -50,10 +50,9 @@ class Configuration {
protected $configPrefix = null;
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 $unsavedChanges = [];

//settings
protected $config = [
Expand Down Expand Up @@ -262,6 +261,7 @@ public function readConfiguration() {
*/
public function saveConfiguration() {
$cta = array_flip($this->getConfigTranslationArray());
$changed = false;
foreach ($this->unsavedChanges as $key) {
$value = $this->config[$key];
switch ($key) {
Expand Down Expand Up @@ -291,9 +291,12 @@ public function saveConfiguration() {
if (is_null($value)) {
$value = '';
}
$changed = true;
$this->saveValue($cta[$key], $value);
}
$this->saveValue('_lastChange', 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 @@ -117,6 +117,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 49cd75b

Please sign in to comment.