diff options
Diffstat (limited to 'lib/private')
-rw-r--r-- | lib/private/AllConfig.php | 6 | ||||
-rw-r--r-- | lib/private/AppConfig.php | 30 | ||||
-rw-r--r-- | lib/private/AppFramework/Bootstrap/RegistrationContext.php | 8 | ||||
-rw-r--r-- | lib/private/Calendar/Manager.php | 10 | ||||
-rw-r--r-- | lib/private/Config/ConfigManager.php | 23 | ||||
-rw-r--r-- | lib/private/Config/Lexicon/CoreConfigLexicon.php | 22 | ||||
-rw-r--r-- | lib/private/Config/UserConfig.php | 46 | ||||
-rw-r--r-- | lib/private/Server.php | 3 | ||||
-rw-r--r-- | lib/private/Updater.php | 7 |
9 files changed, 85 insertions, 70 deletions
diff --git a/lib/private/AllConfig.php b/lib/private/AllConfig.php index 8a6bb5a4723..c80ee52eb0d 100644 --- a/lib/private/AllConfig.php +++ b/lib/private/AllConfig.php @@ -7,11 +7,11 @@ */ namespace OC; -use NCU\Config\Exceptions\TypeConflictException; -use NCU\Config\IUserConfig; -use NCU\Config\ValueType; use OC\Config\UserConfig; use OCP\Cache\CappedMemoryCache; +use OCP\Config\Exceptions\TypeConflictException; +use OCP\Config\IUserConfig; +use OCP\Config\ValueType; use OCP\IConfig; use OCP\IDBConnection; use OCP\PreConditionNotMetException; diff --git a/lib/private/AppConfig.php b/lib/private/AppConfig.php index f050deba1ca..0a46109c9f9 100644 --- a/lib/private/AppConfig.php +++ b/lib/private/AppConfig.php @@ -11,12 +11,12 @@ namespace OC; use InvalidArgumentException; use JsonException; -use NCU\Config\Lexicon\ConfigLexiconEntry; -use NCU\Config\Lexicon\ConfigLexiconStrictness; -use NCU\Config\Lexicon\IConfigLexicon; -use NCU\Config\Lexicon\Preset; use OC\AppFramework\Bootstrap\Coordinator; use OC\Config\ConfigManager; +use OCP\Config\Lexicon\Entry; +use OCP\Config\Lexicon\ILexicon; +use OCP\Config\Lexicon\Preset; +use OCP\Config\Lexicon\Strictness; use OCP\DB\Exception as DBException; use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\Exceptions\AppConfigIncorrectTypeException; @@ -62,7 +62,7 @@ class AppConfig implements IAppConfig { private array $valueTypes = []; // type for all config values private bool $fastLoaded = false; private bool $lazyLoaded = false; - /** @var array<string, array{entries: array<string, ConfigLexiconEntry>, aliases: array<string, string>, strictness: ConfigLexiconStrictness}> ['app_id' => ['strictness' => ConfigLexiconStrictness, 'entries' => ['config_key' => ConfigLexiconEntry[]]] */ + /** @var array<string, array{entries: array<string, Entry>, aliases: array<string, string>, strictness: Strictness}> ['app_id' => ['strictness' => ConfigLexiconStrictness, 'entries' => ['config_key' => ConfigLexiconEntry[]]] */ private array $configLexiconDetails = []; private bool $ignoreLexiconAliases = false; private ?Preset $configLexiconPreset = null; @@ -1655,7 +1655,7 @@ class AppConfig implements IAppConfig { return true; } - /** @var ConfigLexiconEntry $configValue */ + /** @var Entry $configValue */ $configValue = $configDetails['entries'][$key]; $type &= ~self::VALUE_SENSITIVE; @@ -1685,15 +1685,15 @@ class AppConfig implements IAppConfig { /** * manage ConfigLexicon behavior based on strictness set in IConfigLexicon * - * @param ConfigLexiconStrictness|null $strictness + * @param Strictness|null $strictness * @param string $line * * @return bool TRUE if conflict can be fully ignored, FALSE if action should be not performed * @throws AppConfigUnknownKeyException if strictness implies exception - * @see IConfigLexicon::getStrictness() + * @see ILexicon::getStrictness() */ private function applyLexiconStrictness( - ?ConfigLexiconStrictness $strictness, + ?Strictness $strictness, string $line = '', ): bool { if ($strictness === null) { @@ -1701,12 +1701,12 @@ class AppConfig implements IAppConfig { } switch ($strictness) { - case ConfigLexiconStrictness::IGNORE: + case Strictness::IGNORE: return true; - case ConfigLexiconStrictness::NOTICE: + case Strictness::NOTICE: $this->logger->notice($line); return true; - case ConfigLexiconStrictness::WARNING: + case Strictness::WARNING: $this->logger->warning($line); return false; } @@ -1720,7 +1720,7 @@ class AppConfig implements IAppConfig { * @param string $appId * @internal * - * @return array{entries: array<string, ConfigLexiconEntry>, aliases: array<string, string>, strictness: ConfigLexiconStrictness} + * @return array{entries: array<string, Entry>, aliases: array<string, string>, strictness: Strictness} */ public function getConfigDetailsFromLexicon(string $appId): array { if (!array_key_exists($appId, $this->configLexiconDetails)) { @@ -1737,14 +1737,14 @@ class AppConfig implements IAppConfig { $this->configLexiconDetails[$appId] = [ 'entries' => $entries, 'aliases' => $aliases, - 'strictness' => $configLexicon?->getStrictness() ?? ConfigLexiconStrictness::IGNORE + 'strictness' => $configLexicon?->getStrictness() ?? Strictness::IGNORE ]; } return $this->configLexiconDetails[$appId]; } - private function getLexiconEntry(string $appId, string $key): ?ConfigLexiconEntry { + private function getLexiconEntry(string $appId, string $key): ?Entry { return $this->getConfigDetailsFromLexicon($appId)['entries'][$key] ?? null; } diff --git a/lib/private/AppFramework/Bootstrap/RegistrationContext.php b/lib/private/AppFramework/Bootstrap/RegistrationContext.php index 95ad129c466..94250aad37b 100644 --- a/lib/private/AppFramework/Bootstrap/RegistrationContext.php +++ b/lib/private/AppFramework/Bootstrap/RegistrationContext.php @@ -10,7 +10,6 @@ declare(strict_types=1); namespace OC\AppFramework\Bootstrap; use Closure; -use NCU\Config\Lexicon\IConfigLexicon; use OC\Config\Lexicon\CoreConfigLexicon; use OC\Support\CrashReport\Registry; use OCP\AppFramework\App; @@ -23,6 +22,7 @@ use OCP\Calendar\Resource\IBackend as IResourceBackend; use OCP\Calendar\Room\IBackend as IRoomBackend; use OCP\Capabilities\ICapability; use OCP\Collaboration\Reference\IReferenceProvider; +use OCP\Config\Lexicon\ILexicon; use OCP\Dashboard\IManager; use OCP\Dashboard\IWidget; use OCP\EventDispatcher\IEventDispatcher; @@ -652,7 +652,7 @@ class RegistrationContext { } /** - * @psalm-param class-string<IConfigLexicon> $configLexiconClass + * @psalm-param class-string<ILexicon> $configLexiconClass */ public function registerConfigLexicon(string $appId, string $configLexiconClass): void { $this->configLexiconClasses[$appId] = $configLexiconClass; @@ -1023,9 +1023,9 @@ class RegistrationContext { * * @param string $appId * - * @return IConfigLexicon|null + * @return ILexicon|null */ - public function getConfigLexicon(string $appId): ?IConfigLexicon { + public function getConfigLexicon(string $appId): ?ILexicon { if (!array_key_exists($appId, $this->configLexiconClasses)) { return null; } diff --git a/lib/private/Calendar/Manager.php b/lib/private/Calendar/Manager.php index 0e2a3f5f679..7da1379809d 100644 --- a/lib/private/Calendar/Manager.php +++ b/lib/private/Calendar/Manager.php @@ -403,7 +403,10 @@ class Manager implements IManager { } if (empty($found)) { - $this->logger->warning('iMip message event could not be processed because no corresponding event was found in any calendar ' . $principalUri . 'and UID' . $vEvent->{'UID'}->getValue()); + $this->logger->warning('iMip message event could not be processed because no corresponding event was found in any calendar', [ + 'principalUri' => $principalUri, + 'eventUid' => $vEvent->{'UID'}->getValue(), + ]); return false; } @@ -518,7 +521,10 @@ class Manager implements IManager { } if (empty($found)) { - $this->logger->warning('iMip message event could not be processed because no corresponding event was found in any calendar ' . $principalUri . 'and UID' . $vEvent->{'UID'}->getValue()); + $this->logger->warning('iMip message event could not be processed because no corresponding event was found in any calendar', [ + 'principalUri' => $principalUri, + 'eventUid' => $vEvent->{'UID'}->getValue(), + ]); return false; } diff --git a/lib/private/Config/ConfigManager.php b/lib/private/Config/ConfigManager.php index 67466617941..ed516abdcbf 100644 --- a/lib/private/Config/ConfigManager.php +++ b/lib/private/Config/ConfigManager.php @@ -9,13 +9,13 @@ declare(strict_types=1); namespace OC\Config; use JsonException; -use NCU\Config\Exceptions\TypeConflictException; -use NCU\Config\IUserConfig; -use NCU\Config\Lexicon\ConfigLexiconEntry; -use NCU\Config\Lexicon\Preset; -use NCU\Config\ValueType; use OC\AppConfig; use OCP\App\IAppManager; +use OCP\Config\Exceptions\TypeConflictException; +use OCP\Config\IUserConfig; +use OCP\Config\Lexicon\Entry; +use OCP\Config\Lexicon\Preset; +use OCP\Config\ValueType; use OCP\IAppConfig; use OCP\IConfig; use OCP\Server; @@ -50,10 +50,11 @@ class ConfigManager { * * This method should be mainly called during a new upgrade or when a new app is enabled. * - * @see ConfigLexiconEntry + * @param string|null $appId when set to NULL the method will be executed for all enabled apps of the instance + * * @internal * @since 32.0.0 - * @param string|null $appId when set to NULL the method will be executed for all enabled apps of the instance + * @see Entry */ public function migrateConfigLexiconKeys(?string $appId = null): void { if ($appId === null) { @@ -166,7 +167,7 @@ class ConfigManager { * * @throws TypeConflictException if previous value does not fit the expected type */ - private function migrateAppConfigValue(string $appId, ConfigLexiconEntry $entry): void { + private function migrateAppConfigValue(string $appId, Entry $entry): void { $value = $this->appConfig->getValueMixed($appId, $entry->getRename(), lazy: null); switch ($entry->getValueType()) { case ValueType::STRING: @@ -196,7 +197,7 @@ class ConfigManager { * * @throws TypeConflictException if previous value does not fit the expected type */ - private function migrateUserConfigValue(string $userId, string $appId, ConfigLexiconEntry $entry): void { + private function migrateUserConfigValue(string $userId, string $appId, Entry $entry): void { $value = $this->userConfig->getValueMixed($userId, $appId, $entry->getRename(), lazy: null); switch ($entry->getValueType()) { case ValueType::STRING: @@ -237,7 +238,7 @@ class ConfigManager { return (float)$value; } - public function convertToBool(string $value, ?ConfigLexiconEntry $entry = null): bool { + public function convertToBool(string $value, ?Entry $entry = null): bool { if (in_array(strtolower($value), ['true', '1', 'on', 'yes'])) { $valueBool = true; } elseif (in_array(strtolower($value), ['false', '0', 'off', 'no'])) { @@ -245,7 +246,7 @@ class ConfigManager { } else { throw new TypeConflictException('Value cannot be converted to boolean'); } - if ($entry?->hasOption(ConfigLexiconEntry::RENAME_INVERT_BOOLEAN) === true) { + if ($entry?->hasOption(Entry::RENAME_INVERT_BOOLEAN) === true) { $valueBool = !$valueBool; } diff --git a/lib/private/Config/Lexicon/CoreConfigLexicon.php b/lib/private/Config/Lexicon/CoreConfigLexicon.php index 34a0b883c54..de84a58131c 100644 --- a/lib/private/Config/Lexicon/CoreConfigLexicon.php +++ b/lib/private/Config/Lexicon/CoreConfigLexicon.php @@ -8,36 +8,36 @@ declare(strict_types=1); namespace OC\Config\Lexicon; -use NCU\Config\Lexicon\ConfigLexiconEntry; -use NCU\Config\Lexicon\ConfigLexiconStrictness; -use NCU\Config\Lexicon\IConfigLexicon; -use NCU\Config\ValueType; +use OCP\Config\Lexicon\Entry; +use OCP\Config\Lexicon\ILexicon; +use OCP\Config\Lexicon\Strictness; +use OCP\Config\ValueType; /** * ConfigLexicon for 'core' app/user configs */ -class CoreConfigLexicon implements IConfigLexicon { - public function getStrictness(): ConfigLexiconStrictness { - return ConfigLexiconStrictness::IGNORE; +class CoreConfigLexicon implements ILexicon { + public function getStrictness(): Strictness { + return Strictness::IGNORE; } /** * @inheritDoc - * @return ConfigLexiconEntry[] + * @return Entry[] */ public function getAppConfigs(): array { return [ - new ConfigLexiconEntry('lastcron', ValueType::INT, 0, 'timestamp of last cron execution'), + new Entry('lastcron', ValueType::INT, 0, 'timestamp of last cron execution'), ]; } /** * @inheritDoc - * @return ConfigLexiconEntry[] + * @return Entry[] */ public function getUserConfigs(): array { return [ - new ConfigLexiconEntry('lang', ValueType::STRING, null, 'language'), + new Entry('lang', ValueType::STRING, null, 'language'), ]; } } diff --git a/lib/private/Config/UserConfig.php b/lib/private/Config/UserConfig.php index fb0bf954f57..04ba0e29db0 100644 --- a/lib/private/Config/UserConfig.php +++ b/lib/private/Config/UserConfig.php @@ -11,15 +11,16 @@ namespace OC\Config; use Generator; use InvalidArgumentException; use JsonException; -use NCU\Config\Exceptions\IncorrectTypeException; -use NCU\Config\Exceptions\TypeConflictException; -use NCU\Config\Exceptions\UnknownKeyException; -use NCU\Config\IUserConfig; -use NCU\Config\Lexicon\ConfigLexiconEntry; -use NCU\Config\Lexicon\ConfigLexiconStrictness; -use NCU\Config\Lexicon\Preset; -use NCU\Config\ValueType; use OC\AppFramework\Bootstrap\Coordinator; +use OCP\Config\Exceptions\IncorrectTypeException; +use OCP\Config\Exceptions\TypeConflictException; +use OCP\Config\Exceptions\UnknownKeyException; +use OCP\Config\IUserConfig; +use OCP\Config\Lexicon\Entry; +use OCP\Config\Lexicon\ILexicon; +use OCP\Config\Lexicon\Preset; +use OCP\Config\Lexicon\Strictness; +use OCP\Config\ValueType; use OCP\DB\Exception as DBException; use OCP\DB\IResult; use OCP\DB\QueryBuilder\IQueryBuilder; @@ -64,7 +65,7 @@ class UserConfig implements IUserConfig { private array $fastLoaded = []; /** @var array<string, boolean> ['user_id' => bool] */ private array $lazyLoaded = []; - /** @var array<string, array{entries: array<string, ConfigLexiconEntry>, aliases: array<string, string>, strictness: ConfigLexiconStrictness}> ['app_id' => ['strictness' => ConfigLexiconStrictness, 'entries' => ['config_key' => ConfigLexiconEntry[]]] */ + /** @var array<string, array{entries: array<string, Entry>, aliases: array<string, string>, strictness: Strictness}> ['app_id' => ['strictness' => ConfigLexiconStrictness, 'entries' => ['config_key' => ConfigLexiconEntry[]]] */ private array $configLexiconDetails = []; private bool $ignoreLexiconAliases = false; private ?Preset $configLexiconPreset = null; @@ -1913,7 +1914,7 @@ class UserConfig implements IUserConfig { return true; } - /** @var ConfigLexiconEntry $configValue */ + /** @var Entry $configValue */ $configValue = $configDetails['entries'][$key]; if ($type === ValueType::MIXED) { // we overwrite if value was requested as mixed @@ -1954,7 +1955,7 @@ class UserConfig implements IUserConfig { * * The entry is converted to string to fit the expected type when managing default value */ - private function getSystemDefault(string $appId, ConfigLexiconEntry $configValue): ?string { + private function getSystemDefault(string $appId, Entry $configValue): ?string { $default = $this->config->getSystemValue('lexicon.default.userconfig', [])[$appId][$configValue->getKey()] ?? null; if ($default === null) { // no system default, using default default. @@ -1967,28 +1968,28 @@ class UserConfig implements IUserConfig { /** * manage ConfigLexicon behavior based on strictness set in IConfigLexicon * - * @see IConfigLexicon::getStrictness() - * @param ConfigLexiconStrictness|null $strictness + * @param Strictness|null $strictness * @param string $line * * @return bool TRUE if conflict can be fully ignored * @throws UnknownKeyException + *@see ILexicon::getStrictness() */ - private function applyLexiconStrictness(?ConfigLexiconStrictness $strictness, string $line = ''): bool { + private function applyLexiconStrictness(?Strictness $strictness, string $line = ''): bool { if ($strictness === null) { return true; } switch ($strictness) { - case ConfigLexiconStrictness::IGNORE: + case Strictness::IGNORE: return true; - case ConfigLexiconStrictness::NOTICE: + case Strictness::NOTICE: $this->logger->notice($line); return true; - case ConfigLexiconStrictness::WARNING: + case Strictness::WARNING: $this->logger->warning($line); return false; - case ConfigLexiconStrictness::EXCEPTION: + case Strictness::EXCEPTION: throw new UnknownKeyException($line); } @@ -1999,9 +2000,10 @@ class UserConfig implements IUserConfig { * extract details from registered $appId's config lexicon * * @param string $appId - * @internal * - * @return array{entries: array<string, ConfigLexiconEntry>, aliases: array<string, string>, strictness: ConfigLexiconStrictness} + * @return array{entries: array<string, Entry>, aliases: array<string, string>, strictness: Strictness} + *@internal + * */ public function getConfigDetailsFromLexicon(string $appId): array { if (!array_key_exists($appId, $this->configLexiconDetails)) { @@ -2018,14 +2020,14 @@ class UserConfig implements IUserConfig { $this->configLexiconDetails[$appId] = [ 'entries' => $entries, 'aliases' => $aliases, - 'strictness' => $configLexicon?->getStrictness() ?? ConfigLexiconStrictness::IGNORE + 'strictness' => $configLexicon?->getStrictness() ?? Strictness::IGNORE ]; } return $this->configLexiconDetails[$appId]; } - private function getLexiconEntry(string $appId, string $key): ?ConfigLexiconEntry { + private function getLexiconEntry(string $appId, string $key): ?Entry { return $this->getConfigDetailsFromLexicon($appId)['entries'][$key] ?? null; } diff --git a/lib/private/Server.php b/lib/private/Server.php index 1e1ba2a1ad3..d339a97baab 100644 --- a/lib/private/Server.php +++ b/lib/private/Server.php @@ -8,7 +8,6 @@ namespace OC; use bantu\IniGetWrapper\IniGetWrapper; -use NCU\Config\IUserConfig; use NCU\Security\Signature\ISignatureManager; use OC\Accounts\AccountManager; use OC\App\AppManager; @@ -139,6 +138,7 @@ use OCP\BackgroundJob\IJobList; use OCP\Collaboration\Reference\IReferenceManager; use OCP\Command\IBus; use OCP\Comments\ICommentsManager; +use OCP\Config\IUserConfig; use OCP\Contacts\ContactsMenu\IActionFactory; use OCP\Contacts\ContactsMenu\IContactsStore; use OCP\Defaults; @@ -163,7 +163,6 @@ use OCP\Files\Storage\IStorageFactory; use OCP\Files\Template\ITemplateManager; use OCP\FilesMetadata\IFilesMetadataManager; use OCP\FullTextSearch\IFullTextSearchManager; -use OCP\GlobalScale\IConfig; use OCP\Group\ISubAdmin; use OCP\Http\Client\IClientService; use OCP\IAppConfig; diff --git a/lib/private/Updater.php b/lib/private/Updater.php index 6495bad2da2..9cd33863612 100644 --- a/lib/private/Updater.php +++ b/lib/private/Updater.php @@ -385,6 +385,13 @@ class Updater extends BasicEmitter { if ($this->installer->isUpdateAvailable($app)) { $this->emit('\OC\Updater', 'upgradeAppStoreApp', [$app]); $this->installer->updateAppstoreApp($app); + } elseif (!empty($previousEnableStates)) { + /** + * When updating a local app we still need to run updateApp + * so that repair steps and migrations are correctly executed + * Ref: https://github.com/nextcloud/server/issues/53985 + */ + \OC_App::updateApp($app); } $this->emit('\OC\Updater', 'checkAppStoreApp', [$app]); |