diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/AppConfig.php | 29 | ||||
-rw-r--r-- | lib/private/Security/Ip/BruteforceAllowList.php | 5 | ||||
-rw-r--r-- | lib/private/Updater.php | 7 | ||||
-rw-r--r-- | lib/public/IAppConfig.php | 16 |
4 files changed, 51 insertions, 6 deletions
diff --git a/lib/private/AppConfig.php b/lib/private/AppConfig.php index 0eb91fb1be4..f050deba1ca 100644 --- a/lib/private/AppConfig.php +++ b/lib/private/AppConfig.php @@ -95,8 +95,9 @@ class AppConfig implements IAppConfig { * @inheritDoc * * @param string $app id of the app - * * @return list<string> list of stored config keys + * @see searchKeys to not load lazy config keys + * * @since 29.0.0 */ public function getKeys(string $app): array { @@ -112,6 +113,32 @@ class AppConfig implements IAppConfig { * @inheritDoc * * @param string $app id of the app + * @param string $prefix returns only keys starting with this value + * @param bool $lazy TRUE to search in lazy config keys + * @return list<string> list of stored config keys + * @since 32.0.0 + */ + public function searchKeys(string $app, string $prefix = '', bool $lazy = false): array { + $this->assertParams($app); + $this->loadConfig($app, $lazy); + if ($lazy) { + $keys = array_keys($this->lazyCache[$app] ?? []); + } else { + $keys = array_keys($this->fastCache[$app] ?? []); + } + + if ($prefix !== '') { + $keys = array_filter($keys, static fn (string $key): bool => str_starts_with($key, $prefix)); + } + + sort($keys); + return array_values(array_unique($keys)); + } + + /** + * @inheritDoc + * + * @param string $app id of the app * @param string $key config key * @param bool|null $lazy TRUE to search within lazy loaded config, NULL to search within all config * diff --git a/lib/private/Security/Ip/BruteforceAllowList.php b/lib/private/Security/Ip/BruteforceAllowList.php index cc4f0ceebe5..fb837690a7b 100644 --- a/lib/private/Security/Ip/BruteforceAllowList.php +++ b/lib/private/Security/Ip/BruteforceAllowList.php @@ -36,10 +36,7 @@ class BruteforceAllowList { return false; } - $keys = $this->appConfig->getKeys('bruteForce'); - $keys = array_filter($keys, static fn ($key): bool => str_starts_with($key, 'whitelist_')); - - foreach ($keys as $key) { + foreach ($this->appConfig->searchKeys('bruteForce', 'whitelist_') as $key) { $rangeString = $this->appConfig->getValueString('bruteForce', $key); try { $range = $this->factory->rangeFromString($rangeString); 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]); diff --git a/lib/public/IAppConfig.php b/lib/public/IAppConfig.php index fcc528fe11f..68d4332146e 100644 --- a/lib/public/IAppConfig.php +++ b/lib/public/IAppConfig.php @@ -65,13 +65,27 @@ interface IAppConfig { * **WARNING:** ignore lazy filtering, all config values are loaded from database * * @param string $app id of the app - * * @return list<string> list of stored config keys + * @see searchKeys to avoid loading lazy config keys + * * @since 29.0.0 */ public function getKeys(string $app): array; /** + * Returns list of keys stored in database, related to an app. + * Please note that the values are not returned. + * + * @param string $app id of the app + * @param string $prefix returns only keys starting with this value + * @param bool $lazy TRUE to search in lazy config keys + * + * @return list<string> list of stored config keys + * @since 32.0.0 + */ + public function searchKeys(string $app, string $prefix = '', bool $lazy = false): array; + + /** * Check if a key exists in the list of stored config values. * * @param string $app id of the app |