diff --git a/lib/private/AppConfig.php b/lib/private/AppConfig.php index 0887a41b2d0a8..d3c7efcf39b70 100644 --- a/lib/private/AppConfig.php +++ b/lib/private/AppConfig.php @@ -58,6 +58,7 @@ class AppConfig implements IAppConfig { private const int ENCRYPTION_PREFIX_LENGTH = 21; // strlen(self::ENCRYPTION_PREFIX) private const string LOCAL_CACHE_KEY = 'OC\\AppConfig'; private const int LOCAL_CACHE_TTL = 3; + private const int MAX_NON_LAZY_SIZE = 128; // bytes /** @var array> ['app_id' => ['config_key' => 'config_value']] */ private array $fastCache = []; // cache for normal config keys @@ -856,6 +857,17 @@ private function setTypedValue( $value = self::ENCRYPTION_PREFIX . $this->crypto->encrypt($value); } + if (!$lazy && strlen($value) > self::MAX_NON_LAZY_SIZE) { + $this->logger->error( + '[Deprecated] App config {app}:{key} is larger than {maxSize} bytes. It should be declared as lazy.', + [ + 'app' => $app, + 'key' => $key, + 'maxSize' => self::MAX_NON_LAZY_SIZE, + ] + ); + } + if ($this->hasKey($app, $key, $lazy)) { /** * no update if key is already known with set lazy status and value is diff --git a/lib/private/Config/UserConfig.php b/lib/private/Config/UserConfig.php index 2869b590f5e0a..e884b96029d94 100644 --- a/lib/private/Config/UserConfig.php +++ b/lib/private/Config/UserConfig.php @@ -55,6 +55,7 @@ class UserConfig implements IUserConfig { private const int APP_MAX_LENGTH = 32; private const int KEY_MAX_LENGTH = 64; private const int INDEX_MAX_LENGTH = 64; + private const int MAX_NON_LAZY_SIZE = 128; // bytes /** @var CappedMemoryCache>> cache for normal config keys */ private CappedMemoryCache $fastCache; @@ -1153,6 +1154,17 @@ private function setTypedValue( return false; } $this->loadConfig($userId, $lazy); + if (!$lazy && strlen($value) > self::MAX_NON_LAZY_SIZE) { + $this->logger->error( + '[Deprecated] User {userId} config "{app}:{key}" is larger than {maxSize} bytes. It should be declared as lazy.', + [ + 'app' => $app, + 'key' => $key, + 'userId' => $userId, + 'maxSize' => self::MAX_NON_LAZY_SIZE, + ] + ); + } $inserted = $refreshCache = false; $origValue = $value;