fix: resolve invalid usage of `AppConfig::getValue`

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
pull/54383/head
Ferdinand Thiessen 2 months ago
parent 9d320f8470
commit d5e2432bcd
No known key found for this signature in database
GPG Key ID: 45FAE7268762B400
  1. 9
      build/psalm-baseline.xml
  2. 4
      core/Command/Encryption/Enable.php
  3. 6
      lib/private/AppConfig.php
  4. 2
      lib/private/Installer.php
  5. 2
      lib/private/legacy/OC_App.php
  6. 8
      tests/Core/Command/Encryption/EnableTest.php

@ -2980,9 +2980,6 @@
<code><![CDATA[getAppValue]]></code>
<code><![CDATA[setAppValue]]></code>
</DeprecatedMethod>
<NullArgument>
<code><![CDATA[null]]></code>
</NullArgument>
</file>
<file src="core/Command/Encryption/MigrateKeyStorage.php">
<DeprecatedClass>
@ -4010,9 +4007,6 @@
<code><![CDATA[false]]></code>
<code><![CDATA[false]]></code>
</InvalidArgument>
<NullArgument>
<code><![CDATA[null]]></code>
</NullArgument>
</file>
<file src="lib/private/IntegrityCheck/Checker.php">
<InvalidArrayAccess>
@ -4389,9 +4383,6 @@
<InvalidArgument>
<code><![CDATA[$groupsList]]></code>
</InvalidArgument>
<NullArgument>
<code><![CDATA[null]]></code>
</NullArgument>
</file>
<file src="lib/private/legacy/OC_Helper.php">
<InvalidArrayOffset>

@ -42,8 +42,8 @@ class Enable extends Command {
$output->writeln('<error>No encryption module is loaded</error>');
return 1;
}
$defaultModule = $this->config->getAppValue('core', 'default_encryption_module', null);
if ($defaultModule === null) {
$defaultModule = $this->config->getAppValue('core', 'default_encryption_module');
if ($defaultModule === '') {
$output->writeln('<error>No default module is set</error>');
return 1;
}

@ -1386,15 +1386,15 @@ class AppConfig implements IAppConfig {
*
* @param string $app app
* @param string $key key
* @param string $default = null, default value if the key does not exist
* @param string $default - Default value if the key does not exist
*
* @return ?string the value or $default
* @return string the value or $default
* @deprecated 29.0.0 use getValue*()
*
* This function gets a value from the appconfig table. If the key does
* not exist the default value will be returned
*/
public function getValue($app, $key, $default = null) {
public function getValue($app, $key, $default = '') {
$this->loadConfig($app);
$this->matchAndApplyLexiconDefinition($app, $key);

@ -546,7 +546,7 @@ class Installer {
while (false !== ($filename = readdir($dir))) {
if ($filename[0] !== '.' and is_dir($app_dir['path'] . "/$filename")) {
if (file_exists($app_dir['path'] . "/$filename/appinfo/info.xml")) {
if ($config->getAppValue($filename, 'installed_version', null) === null) {
if ($config->getAppValue($filename, 'installed_version') === '') {
$enabled = $appManager->isDefaultEnabled($filename);
if (($enabled || in_array($filename, $appManager->getAlwaysEnabledApps()))
&& $config->getAppValue($filename, 'enabled') !== 'no') {

@ -685,7 +685,7 @@ class OC_App {
//set remote/public handlers
if (array_key_exists('ocsid', $appData)) {
\OC::$server->getConfig()->setAppValue($appId, 'ocsid', $appData['ocsid']);
} elseif (\OC::$server->getConfig()->getAppValue($appId, 'ocsid', null) !== null) {
} elseif (\OC::$server->getConfig()->getAppValue($appId, 'ocsid') !== '') {
\OC::$server->getConfig()->deleteAppValue($appId, 'ocsid');
}
foreach ($appData['remote'] as $name => $path) {

@ -48,9 +48,9 @@ class EnableTest extends TestCase {
public static function dataEnable(): array {
return [
['no', null, [], true, 'Encryption enabled', 'No encryption module is loaded'],
['yes', null, [], false, 'Encryption is already enabled', 'No encryption module is loaded'],
['no', null, ['OC_TEST_MODULE' => []], true, 'Encryption enabled', 'No default module is set'],
['no', '', [], true, 'Encryption enabled', 'No encryption module is loaded'],
['yes', '', [], false, 'Encryption is already enabled', 'No encryption module is loaded'],
['no', '', ['OC_TEST_MODULE' => []], true, 'Encryption enabled', 'No default module is set'],
['no', 'OC_NO_MODULE', ['OC_TEST_MODULE' => []], true, 'Encryption enabled', 'The current default module does not exist: OC_NO_MODULE'],
['no', 'OC_TEST_MODULE', ['OC_TEST_MODULE' => []], true, 'Encryption enabled', 'Default module: OC_TEST_MODULE'],
];
@ -79,7 +79,7 @@ class EnableTest extends TestCase {
->method('getAppValue')
->willReturnMap([
['core', 'encryption_enabled', 'no', $oldStatus],
['core', 'default_encryption_module', null, $defaultModule],
['core', 'default_encryption_module', '', $defaultModule],
]);
}

Loading…
Cancel
Save