refactor(encryption): Migrate appconfig keys to typed bool IAppConfig with repair step#60002
refactor(encryption): Migrate appconfig keys to typed bool IAppConfig with repair step#60002cuppett wants to merge 6 commits intonextcloud:masterfrom
Conversation
cuppett
left a comment
There was a problem hiding this comment.
I don't know the convention when trying to refactor the legacy values out. Happy to simplify to only the minimal set or wait until next version for another PR. Just LMK.
864ad6a to
f3679b4
Compare
f3679b4 to
39b6d31
Compare
a6fff8f to
e4f6ece
Compare
e5291af to
07461ee
Compare
|
The psalm things (DAV) seem to be coming from the master branch (not related to this PR). Do I need to fix that or can it be overridden to merge? |
artonge
left a comment
There was a problem hiding this comment.
Looks good, thanks for splitting :)
The psalm error is indeed unrelated.
6e52b67 to
c4baa76
Compare
c4baa76 to
ef7b789
Compare
ef7b789 to
9f0c402
Compare
… with repair step Switch all encryption config reads/writes from deprecated string-typed IConfig to bool-typed IAppConfig (getValueBool/setValueBool). Adds RetypeEncryptionConfigKeys repair step to retype existing string values to bool on upgrade. Includes lazy IAppConfig resolution in Manager and AppConfigTypeConflictException fallbacks throughout for safety during the upgrade window. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Stephen Cuppett <steve@cuppett.com>
Signed-off-by: Stephen Cuppett <steve@cuppett.com>
Apply suggestion from @artonge Co-authored-by: Louis <louis@chmn.me> Signed-off-by: Stephen Cuppett <steve@cuppett.com>
Co-authored-by: Louis <louis@chmn.me> Signed-off-by: Stephen Cuppett <steve@cuppett.com>
The IAppConfig API converts stored values to bool on read (getValueBool) and re-stamps the type on write (setValueBool), so legacy string-typed encryption config keys migrate lazily without an explicit repair step. Per PR review feedback, drop the repair step, its test, and the related AppConfigTypeConflictException fallback in Encryption\Manager::isEnabled that only existed to bridge the now-unneeded migration window. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Signed-off-by: Stephen Cuppett <steve@cuppett.com>
… to match strict 'yes'-only validation The verifyConfigKey check on core.encryption_enabled was reverted to master's strict $value !== 'yes' in 626fadd per review feedback, but the test data providers still asserted the broader truthy set (1/true/YES/on). Drop those entries so the tests match the controller. This is validation, not storage — IAppConfig::setValueBool's broader input handling is unrelated. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Signed-off-by: Stephen Cuppett <steve@cuppett.com>
9f0c402 to
1db5b05
Compare
provokateurin
left a comment
There was a problem hiding this comment.
Thanks for the PR. I think it's not complete yet and a little bit more work to do.
| if ($app === 'encryption' && $key === 'recoveryAdminEnabled' && $default === '0') { | ||
| return '1'; | ||
| } |
There was a problem hiding this comment.
This should also be migrated to getValueBool
| <code><![CDATA[getAppValue]]></code> | ||
| <code><![CDATA[getAppValue]]></code> | ||
| <code><![CDATA[getUserValue]]></code> | ||
| <code><![CDATA[setAppValue]]></code> | ||
| <code><![CDATA[setUserValue]]></code> |
There was a problem hiding this comment.
All of these should be migrated
| } | ||
|
|
||
| $originallyEnabled = $this->appConfig->getValueBool('core', 'encryption_enabled'); | ||
| $originallyEnabled = $this->appConfig->getValueBool('core', 'encryption_enabled', false); |
There was a problem hiding this comment.
Unnecessary change, since the default is already false.
| #[\Override] | ||
| protected function execute(InputInterface $input, OutputInterface $output): int { | ||
| if ($this->config->getAppValue('core', 'encryption_enabled', 'no') === 'yes') { | ||
| $isEnabled = $this->appConfig->getValueBool('core', 'encryption_enabled', false); |
There was a problem hiding this comment.
| $isEnabled = $this->appConfig->getValueBool('core', 'encryption_enabled', false); | |
| $isEnabled = $this->appConfig->getValueBool('core', 'encryption_enabled'); |
Also unnecessary default value.
| return 1; | ||
| } | ||
| $defaultModule = $this->config->getAppValue('core', 'default_encryption_module'); | ||
| $defaultModule = $this->appConfig->getValueString('core', 'default_encryption_module', ''); |
There was a problem hiding this comment.
| $defaultModule = $this->appConfig->getValueString('core', 'default_encryption_module', ''); | |
| $defaultModule = $this->appConfig->getValueString('core', 'default_encryption_module'); |
Already the default.
| $enabled = $this->config->getAppValue('core', 'encryption_enabled', 'no'); | ||
| return $enabled === 'yes'; | ||
| try { | ||
| return Server::get(\OCP\IAppConfig::class)->getValueBool('core', 'encryption_enabled', false); |
There was a problem hiding this comment.
It's better if you inject IAppConfig into this class.
| $enabled = $this->config->getAppValue('core', 'encryption_enabled', 'no'); | ||
| return $enabled === 'yes'; | ||
| try { | ||
| return Server::get(\OCP\IAppConfig::class)->getValueBool('core', 'encryption_enabled', false); |
There was a problem hiding this comment.
| return Server::get(\OCP\IAppConfig::class)->getValueBool('core', 'encryption_enabled', false); | |
| return Server::get(\OCP\IAppConfig::class)->getValueBool('core', 'encryption_enabled); |
| /** | ||
| * @group DB | ||
| */ |
There was a problem hiding this comment.
| /** | |
| * @group DB | |
| */ | |
| #[Group(name: 'DB')] |
Summary
Switch all encryption config reads/writes from deprecated string-typed IConfig to bool-typed IAppConfig (getValueBool/setValueBool). Adds RetypeEncryptionConfigKeys repair step to retype existing string values to bool on upgrade. Includes lazy IAppConfig resolution in Manager and AppConfigTypeConflictException fallbacks throughout for safety during the upgrade window.
conflict between new type (mixed) and old type (boolean)#58778Checklist
3. to review, feature component)stable32)AI (if applicable)