aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaxence Lange <maxence@artificial-owl.com>2024-11-18 20:09:45 -0100
committerMaxence Lange <maxence@artificial-owl.com>2024-11-18 20:11:31 -0100
commit5b4f1904c0867b14237c5fcfb3e27e936f35ca0b (patch)
treebf387cc719e3cc8425cfcebe45412432c9304ab6
parent6afc8552b7c0dcd96c88533f47bc8b55cba327c9 (diff)
downloadnextcloud-server-5b4f1904c0867b14237c5fcfb3e27e936f35ca0b.tar.gz
nextcloud-server-5b4f1904c0867b14237c5fcfb3e27e936f35ca0b.zip
feat(user-prefs): renaming to IUserConfigenh/noid/user-preferences
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
-rw-r--r--lib/composer/composer/autoload_classmap.php4
-rw-r--r--lib/composer/composer/autoload_static.php4
-rw-r--r--lib/private/AllConfig.php84
-rw-r--r--lib/private/Config/UserConfig.php (renamed from lib/private/Config/UserPreferences.php)338
-rw-r--r--lib/private/Server.php4
-rw-r--r--lib/public/IConfig.php2
-rw-r--r--lib/unstable/Config/Exceptions/IncorrectTypeException.php1
-rw-r--r--lib/unstable/Config/Exceptions/TypeConflictException.php1
-rw-r--r--lib/unstable/Config/Exceptions/UnknownKeyException.php1
-rw-r--r--lib/unstable/Config/IUserConfig.php (renamed from lib/unstable/Config/IUserPreferences.php)332
-rw-r--r--lib/unstable/Config/ValueType.php1
-rw-r--r--tests/lib/Config/UserConfigTest.php (renamed from tests/lib/UserPreferencesTest.php)330
12 files changed, 559 insertions, 543 deletions
diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php
index 7ba1e0e4667..cc6b8be326c 100644
--- a/lib/composer/composer/autoload_classmap.php
+++ b/lib/composer/composer/autoload_classmap.php
@@ -10,7 +10,7 @@ return array(
'NCU\\Config\\Exceptions\\IncorrectTypeException' => $baseDir . '/lib/unstable/Config/Exceptions/IncorrectTypeException.php',
'NCU\\Config\\Exceptions\\TypeConflictException' => $baseDir . '/lib/unstable/Config/Exceptions/TypeConflictException.php',
'NCU\\Config\\Exceptions\\UnknownKeyException' => $baseDir . '/lib/unstable/Config/Exceptions/UnknownKeyException.php',
- 'NCU\\Config\\IUserPreferences' => $baseDir . '/lib/unstable/Config/IUserPreferences.php',
+ 'NCU\\Config\\IUserConfig' => $baseDir . '/lib/unstable/Config/IUserConfig.php',
'NCU\\Config\\ValueType' => $baseDir . '/lib/unstable/Config/ValueType.php',
'OCP\\Accounts\\IAccount' => $baseDir . '/lib/public/Accounts/IAccount.php',
'OCP\\Accounts\\IAccountManager' => $baseDir . '/lib/public/Accounts/IAccountManager.php',
@@ -1123,7 +1123,7 @@ return array(
'OC\\Comments\\Manager' => $baseDir . '/lib/private/Comments/Manager.php',
'OC\\Comments\\ManagerFactory' => $baseDir . '/lib/private/Comments/ManagerFactory.php',
'OC\\Config' => $baseDir . '/lib/private/Config.php',
- 'OC\\Config\\UserPreferences' => $baseDir . '/lib/private/Config/UserPreferences.php',
+ 'OC\\Config\\UserConfig' => $baseDir . '/lib/private/Config/UserConfig.php',
'OC\\Console\\Application' => $baseDir . '/lib/private/Console/Application.php',
'OC\\Console\\TimestampFormatter' => $baseDir . '/lib/private/Console/TimestampFormatter.php',
'OC\\ContactsManager' => $baseDir . '/lib/private/ContactsManager.php',
diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php
index cf1d395fd43..54959bc6b91 100644
--- a/lib/composer/composer/autoload_static.php
+++ b/lib/composer/composer/autoload_static.php
@@ -51,7 +51,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
'NCU\\Config\\Exceptions\\IncorrectTypeException' => __DIR__ . '/../../..' . '/lib/unstable/Config/Exceptions/IncorrectTypeException.php',
'NCU\\Config\\Exceptions\\TypeConflictException' => __DIR__ . '/../../..' . '/lib/unstable/Config/Exceptions/TypeConflictException.php',
'NCU\\Config\\Exceptions\\UnknownKeyException' => __DIR__ . '/../../..' . '/lib/unstable/Config/Exceptions/UnknownKeyException.php',
- 'NCU\\Config\\IUserPreferences' => __DIR__ . '/../../..' . '/lib/unstable/Config/IUserPreferences.php',
+ 'NCU\\Config\\IUserConfig' => __DIR__ . '/../../..' . '/lib/unstable/Config/IUserConfig.php',
'NCU\\Config\\ValueType' => __DIR__ . '/../../..' . '/lib/unstable/Config/ValueType.php',
'OCP\\Accounts\\IAccount' => __DIR__ . '/../../..' . '/lib/public/Accounts/IAccount.php',
'OCP\\Accounts\\IAccountManager' => __DIR__ . '/../../..' . '/lib/public/Accounts/IAccountManager.php',
@@ -1164,7 +1164,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
'OC\\Comments\\Manager' => __DIR__ . '/../../..' . '/lib/private/Comments/Manager.php',
'OC\\Comments\\ManagerFactory' => __DIR__ . '/../../..' . '/lib/private/Comments/ManagerFactory.php',
'OC\\Config' => __DIR__ . '/../../..' . '/lib/private/Config.php',
- 'OC\\Config\\UserPreferences' => __DIR__ . '/../../..' . '/lib/private/Config/UserPreferences.php',
+ 'OC\\Config\\UserConfig' => __DIR__ . '/../../..' . '/lib/private/Config/UserConfig.php',
'OC\\Console\\Application' => __DIR__ . '/../../..' . '/lib/private/Console/Application.php',
'OC\\Console\\TimestampFormatter' => __DIR__ . '/../../..' . '/lib/private/Console/TimestampFormatter.php',
'OC\\ContactsManager' => __DIR__ . '/../../..' . '/lib/private/ContactsManager.php',
diff --git a/lib/private/AllConfig.php b/lib/private/AllConfig.php
index dbea65fdc21..bb15adf31b4 100644
--- a/lib/private/AllConfig.php
+++ b/lib/private/AllConfig.php
@@ -7,9 +7,9 @@
namespace OC;
use NCU\Config\Exceptions\TypeConflictException;
-use NCU\Config\IUserPreferences;
+use NCU\Config\IUserConfig;
use NCU\Config\ValueType;
-use OC\Config\UserPreferences;
+use OC\Config\UserConfig;
use OCP\Cache\CappedMemoryCache;
use OCP\IConfig;
use OCP\IDBConnection;
@@ -230,20 +230,20 @@ class AllConfig implements IConfig {
*
* @throws \OCP\PreConditionNotMetException if a precondition is specified and is not met
* @throws \UnexpectedValueException when trying to store an unexpected value
- * @deprecated 31.0.0 - use {@see IUserPreferences} directly
- * @see IUserPreferences::getValueString
- * @see IUserPreferences::getValueInt
- * @see IUserPreferences::getValueFloat
- * @see IUserPreferences::getValueArray
- * @see IUserPreferences::getValueBool
+ * @deprecated 31.0.0 - use {@see IUserConfig} directly
+ * @see IUserConfig::getValueString
+ * @see IUserConfig::getValueInt
+ * @see IUserConfig::getValueFloat
+ * @see IUserConfig::getValueArray
+ * @see IUserConfig::getValueBool
*/
public function setUserValue($userId, $appName, $key, $value, $preCondition = null) {
if (!is_int($value) && !is_float($value) && !is_string($value)) {
throw new \UnexpectedValueException('Only integers, floats and strings are allowed as value');
}
- /** @var UserPreferences $userPreferences */
- $userPreferences = \OCP\Server::get(IUserPreferences::class);
+ /** @var UserConfig $userPreferences */
+ $userPreferences = \OCP\Server::get(IUserConfig::class);
if ($preCondition !== null) {
try {
if ($userPreferences->getValueMixed($userId, $appName, $key) !== (string)$preCondition) {
@@ -265,19 +265,19 @@ class AllConfig implements IConfig {
* @param mixed $default the default value to be returned if the value isn't set
*
* @return string
- * @deprecated 31.0.0 - use {@see IUserPreferences} directly
- * @see IUserPreferences::getValueString
- * @see IUserPreferences::getValueInt
- * @see IUserPreferences::getValueFloat
- * @see IUserPreferences::getValueArray
- * @see IUserPreferences::getValueBool
+ * @deprecated 31.0.0 - use {@see IUserConfig} directly
+ * @see IUserConfig::getValueString
+ * @see IUserConfig::getValueInt
+ * @see IUserConfig::getValueFloat
+ * @see IUserConfig::getValueArray
+ * @see IUserConfig::getValueBool
*/
public function getUserValue($userId, $appName, $key, $default = '') {
if ($userId === null || $userId === '') {
return $default;
}
- /** @var UserPreferences $userPreferences */
- $userPreferences = \OCP\Server::get(IUserPreferences::class);
+ /** @var UserConfig $userPreferences */
+ $userPreferences = \OCP\Server::get(IUserConfig::class);
// because $default can be null ...
if (!$userPreferences->hasKey($userId, $appName, $key)) {
return $default;
@@ -290,11 +290,12 @@ class AllConfig implements IConfig {
*
* @param string $userId the userId of the user that we want to store the value under
* @param string $appName the appName that we stored the value under
+ *
* @return string[]
- * @deprecated 31.0.0 - use {@see IUserPreferences::getKeys} directly
+ * @deprecated 31.0.0 - use {@see IUserConfig::getKeys} directly
*/
public function getUserKeys($userId, $appName) {
- return \OCP\Server::get(IUserPreferences::class)->getKeys($userId, $appName);
+ return \OCP\Server::get(IUserConfig::class)->getKeys($userId, $appName);
}
/**
@@ -303,52 +304,56 @@ class AllConfig implements IConfig {
* @param string $userId the userId of the user that we want to store the value under
* @param string $appName the appName that we stored the value under
* @param string $key the key under which the value is being stored
- * @deprecated 31.0.0 - use {@see IUserPreferences::deletePreference} directly
+ *
+ * @deprecated 31.0.0 - use {@see IUserConfig::deleteUserConfig} directly
*/
public function deleteUserValue($userId, $appName, $key) {
- \OCP\Server::get(IUserPreferences::class)->deletePreference($userId, $appName, $key);
+ \OCP\Server::get(IUserConfig::class)->deleteUserConfig($userId, $appName, $key);
}
/**
* Delete all user values
*
* @param string $userId the userId of the user that we want to remove all values from
- * @deprecated 31.0.0 - use {@see IUserPreferences::deleteAllPreferences} directly
+ *
+ * @deprecated 31.0.0 - use {@see IUserConfig::deleteAllUserConfig} directly
*/
public function deleteAllUserValues($userId) {
if ($userId === null) {
return;
}
- \OCP\Server::get(IUserPreferences::class)->deleteAllPreferences($userId);
+ \OCP\Server::get(IUserConfig::class)->deleteAllUserConfig($userId);
}
/**
* Delete all user related values of one app
*
* @param string $appName the appName of the app that we want to remove all values from
- * @deprecated 31.0.0 - use {@see IUserPreferences::deleteApp} directly
+ *
+ * @deprecated 31.0.0 - use {@see IUserConfig::deleteApp} directly
*/
public function deleteAppFromAllUsers($appName) {
- \OCP\Server::get(IUserPreferences::class)->deleteApp($appName);
+ \OCP\Server::get(IUserConfig::class)->deleteApp($appName);
}
/**
* Returns all user configs sorted by app of one user
*
* @param ?string $userId the user ID to get the app configs from
+ *
* @psalm-return array<string, array<string, string>>
* @return array[] - 2 dimensional array with the following structure:
* [ $appId =>
* [ $key => $value ]
* ]
- * @deprecated 31.0.0 - use {@see IUserPreferences::getAllValues} directly
+ * @deprecated 31.0.0 - use {@see IUserConfig::getAllValues} directly
*/
public function getAllUserValues(?string $userId): array {
if ($userId === null || $userId === '') {
return [];
}
- $values = \OCP\Server::get(IUserPreferences::class)->getAllValues($userId);
+ $values = \OCP\Server::get(IUserConfig::class)->getAllValues($userId);
$result = [];
foreach ($values as $app => $list) {
foreach ($list as $key => $value) {
@@ -364,11 +369,12 @@ class AllConfig implements IConfig {
* @param string $appName app to get the value for
* @param string $key the key to get the value for
* @param array $userIds the user IDs to fetch the values for
+ *
* @return array Mapped values: userId => value
- * @deprecated 31.0.0 - use {@see IUserPreferences::getValuesByUsers} directly
+ * @deprecated 31.0.0 - use {@see IUserConfig::getValuesByUsers} directly
*/
public function getUserValueForUsers($appName, $key, $userIds) {
- return \OCP\Server::get(IUserPreferences::class)->getValuesByUsers($appName, $key, ValueType::MIXED, $userIds);
+ return \OCP\Server::get(IUserConfig::class)->getValuesByUsers($appName, $key, ValueType::MIXED, $userIds);
}
/**
@@ -377,11 +383,14 @@ class AllConfig implements IConfig {
* @param string $appName the app to get the user for
* @param string $key the key to get the user for
* @param string $value the value to get the user for
- * @return array<string> of user IDs
- * @deprecated 31.0.0 - use {@see IUserPreferences::searchUsersByValueString} directly
+ *
+ * @return list<string> of user IDs
+ * @deprecated 31.0.0 - use {@see IUserConfig::searchUsersByValueString} directly
*/
public function getUsersForUserValue($appName, $key, $value) {
- return iterator_to_array(\OCP\Server::get(IUserPreferences::class)->searchUsersByValueString($appName, $key, $value));
+ /** @var list<string> $result */
+ $result = iterator_to_array(\OCP\Server::get(IUserConfig::class)->searchUsersByValueString($appName, $key, $value));
+ return $result;
}
/**
@@ -390,15 +399,18 @@ class AllConfig implements IConfig {
* @param string $appName the app to get the user for
* @param string $key the key to get the user for
* @param string $value the value to get the user for
- * @return array<string> of user IDs
- * @deprecated 31.0.0 - use {@see IUserPreferences::searchUsersByValueString} directly
+ *
+ * @return list<string> of user IDs
+ * @deprecated 31.0.0 - use {@see IUserConfig::searchUsersByValueString} directly
*/
public function getUsersForUserValueCaseInsensitive($appName, $key, $value) {
if ($appName === 'settings' && $key === 'email') {
return $this->getUsersForUserValue($appName, $key, strtolower($value));
}
- return iterator_to_array(\OCP\Server::get(IUserPreferences::class)->searchUsersByValueString($appName, $key, $value, true));
+ /** @var list<string> $result */
+ $result = iterator_to_array(\OCP\Server::get(IUserConfig::class)->searchUsersByValueString($appName, $key, $value, true));
+ return $result;
}
public function getSystemConfig() {
diff --git a/lib/private/Config/UserPreferences.php b/lib/private/Config/UserConfig.php
index d9fd5f6a064..37e109b2121 100644
--- a/lib/private/Config/UserPreferences.php
+++ b/lib/private/Config/UserConfig.php
@@ -14,7 +14,7 @@ use JsonException;
use NCU\Config\Exceptions\IncorrectTypeException;
use NCU\Config\Exceptions\TypeConflictException;
use NCU\Config\Exceptions\UnknownKeyException;
-use NCU\Config\IUserPreferences;
+use NCU\Config\IUserConfig;
use NCU\Config\ValueType;
use OCP\DB\Exception as DBException;
use OCP\DB\IResult;
@@ -25,12 +25,12 @@ use OCP\Security\ICrypto;
use Psr\Log\LoggerInterface;
/**
- * This class provides an easy way for apps to store user preferences in the
+ * This class provides an easy way for apps to store user config in the
* database.
* Supports **lazy loading**
*
* ### What is lazy loading ?
- * In order to avoid loading useless user preferences into memory for each request,
+ * In order to avoid loading useless user config into memory for each request,
* only non-lazy values are now loaded.
*
* Once a value that is lazy is requested, all lazy values will be loaded.
@@ -41,24 +41,24 @@ use Psr\Log\LoggerInterface;
*
* @since 31.0.0
*/
-class UserPreferences implements IUserPreferences {
+class UserConfig implements IUserConfig {
private const USER_MAX_LENGTH = 64;
private const APP_MAX_LENGTH = 32;
private const KEY_MAX_LENGTH = 64;
private const INDEX_MAX_LENGTH = 64;
- private const ENCRYPTION_PREFIX = '$UserPreferencesEncryption$';
- private const ENCRYPTION_PREFIX_LENGTH = 27; // strlen(self::ENCRYPTION_PREFIX)
+ private const ENCRYPTION_PREFIX = '$UserConfigEncryption$';
+ private const ENCRYPTION_PREFIX_LENGTH = 22; // strlen(self::ENCRYPTION_PREFIX)
/** @var array<string, array<string, array<string, mixed>>> [ass'user_id' => ['app_id' => ['key' => 'value']]] */
- private array $fastCache = []; // cache for normal preference keys
+ private array $fastCache = []; // cache for normal config keys
/** @var array<string, array<string, array<string, mixed>>> ['user_id' => ['app_id' => ['key' => 'value']]] */
- private array $lazyCache = []; // cache for lazy preference keys
+ private array $lazyCache = []; // cache for lazy config keys
/** @var array<string, array<string, array<string, array<string, mixed>>>> ['user_id' => ['app_id' => ['key' => ['type' => ValueType, 'flags' => bitflag]]]] */
- private array $valueDetails = []; // type for all preference values
+ private array $valueDetails = []; // type for all config values
/** @var array<string, array<string, array<string, ValueType>>> ['user_id' => ['app_id' => ['key' => bitflag]]] */
- private array $valueTypes = []; // type for all preference values
+ private array $valueTypes = []; // type for all config values
/** @var array<string, array<string, array<string, int>>> ['user_id' => ['app_id' => ['key' => bitflag]]] */
- private array $valueFlags = []; // type for all preference values
+ private array $valueFlags = []; // type for all config values
/** @var array<string, boolean> ['user_id' => bool] */
private array $fastLoaded = [];
/** @var array<string, boolean> ['user_id' => bool] */
@@ -108,7 +108,7 @@ class UserPreferences implements IUserPreferences {
*/
public function getApps(string $userId): array {
$this->assertParams($userId, allowEmptyApp: true);
- $this->loadPreferencesAll($userId);
+ $this->loadConfigAll($userId);
$apps = array_merge(array_keys($this->fastCache[$userId] ?? []), array_keys($this->lazyCache[$userId] ?? []));
sort($apps);
@@ -121,13 +121,13 @@ class UserPreferences implements IUserPreferences {
* @param string $userId id of the user
* @param string $app id of the app
*
- * @return list<string> list of stored preference keys
+ * @return list<string> list of stored config keys
* @since 31.0.0
*/
public function getKeys(string $userId, string $app): array {
$this->assertParams($userId, $app);
- $this->loadPreferencesAll($userId);
- // array_merge() will remove numeric keys (here preference keys), so addition arrays instead
+ $this->loadConfigAll($userId);
+ // array_merge() will remove numeric keys (here config keys), so addition arrays instead
$keys = array_map('strval', array_keys(($this->fastCache[$userId][$app] ?? []) + ($this->lazyCache[$userId][$app] ?? [])));
sort($keys);
@@ -139,15 +139,15 @@ class UserPreferences implements IUserPreferences {
*
* @param string $userId id of the user
* @param string $app id of the app
- * @param string $key preference key
- * @param bool|null $lazy TRUE to search within lazy loaded preferences, NULL to search within all preferences
+ * @param string $key config key
+ * @param bool|null $lazy TRUE to search within lazy loaded config, NULL to search within all config
*
* @return bool TRUE if key exists
* @since 31.0.0
*/
public function hasKey(string $userId, string $app, string $key, ?bool $lazy = false): bool {
$this->assertParams($userId, $app, $key);
- $this->loadPreferences($userId, $lazy);
+ $this->loadConfig($userId, $lazy);
if ($lazy === null) {
$appCache = $this->getValues($userId, $app);
@@ -166,19 +166,19 @@ class UserPreferences implements IUserPreferences {
*
* @param string $userId id of the user
* @param string $app id of the app
- * @param string $key preference key
- * @param bool|null $lazy TRUE to search within lazy loaded preferences, NULL to search within all preferences
+ * @param string $key config key
+ * @param bool|null $lazy TRUE to search within lazy loaded config, NULL to search within all config
*
* @return bool
- * @throws UnknownKeyException if preference key is not known
+ * @throws UnknownKeyException if config key is not known
* @since 31.0.0
*/
public function isSensitive(string $userId, string $app, string $key, ?bool $lazy = false): bool {
$this->assertParams($userId, $app, $key);
- $this->loadPreferences($userId, $lazy);
+ $this->loadConfig($userId, $lazy);
if (!isset($this->valueDetails[$userId][$app][$key])) {
- throw new UnknownKeyException('unknown preference key');
+ throw new UnknownKeyException('unknown config key');
}
return $this->isFlagged(self::FLAG_SENSITIVE, $this->valueDetails[$userId][$app][$key]['flags']);
@@ -189,19 +189,19 @@ class UserPreferences implements IUserPreferences {
*
* @param string $userId id of the user
* @param string $app id of the app
- * @param string $key preference key
- * @param bool|null $lazy TRUE to search within lazy loaded preferences, NULL to search within all preferences
+ * @param string $key config key
+ * @param bool|null $lazy TRUE to search within lazy loaded config, NULL to search within all config
*
* @return bool
- * @throws UnknownKeyException if preference key is not known
+ * @throws UnknownKeyException if config key is not known
* @since 31.0.0
*/
public function isIndexed(string $userId, string $app, string $key, ?bool $lazy = false): bool {
$this->assertParams($userId, $app, $key);
- $this->loadPreferences($userId, $lazy);
+ $this->loadConfig($userId, $lazy);
if (!isset($this->valueDetails[$userId][$app][$key])) {
- throw new UnknownKeyException('unknown preference key');
+ throw new UnknownKeyException('unknown config key');
}
return $this->isFlagged(self::FLAG_INDEXED, $this->valueDetails[$userId][$app][$key]['flags']);
@@ -212,26 +212,26 @@ class UserPreferences implements IUserPreferences {
*
* @param string $userId id of the user
* @param string $app if of the app
- * @param string $key preference key
+ * @param string $key config key
*
- * @return bool TRUE if preference is lazy loaded
- * @throws UnknownKeyException if preference key is not known
- * @see IUserPreferences for details about lazy loading
+ * @return bool TRUE if config is lazy loaded
+ * @throws UnknownKeyException if config key is not known
+ * @see IUserConfig for details about lazy loading
* @since 31.0.0
*/
public function isLazy(string $userId, string $app, string $key): bool {
- // there is a huge probability the non-lazy preferences are already loaded
+ // there is a huge probability the non-lazy config are already loaded
// meaning that we can start by only checking if a current non-lazy key exists
if ($this->hasKey($userId, $app, $key, false)) {
return false; // meaning key is not lazy.
}
- // as key is not found as non-lazy, we load and search in the lazy preferences
+ // as key is not found as non-lazy, we load and search in the lazy config
if ($this->hasKey($userId, $app, $key, true)) {
return true;
}
- throw new UnknownKeyException('unknown preference key');
+ throw new UnknownKeyException('unknown config key');
}
/**
@@ -239,8 +239,8 @@ class UserPreferences implements IUserPreferences {
*
* @param string $userId id of the user
* @param string $app id of the app
- * @param string $prefix preference keys prefix to search
- * @param bool $filtered TRUE to hide sensitive preference values. Value are replaced by {@see IConfig::SENSITIVE_VALUE}
+ * @param string $prefix config keys prefix to search
+ * @param bool $filtered TRUE to hide sensitive config values. Value are replaced by {@see IConfig::SENSITIVE_VALUE}
*
* @return array<string, string|int|float|bool|array> [key => value]
* @since 31.0.0
@@ -253,8 +253,8 @@ class UserPreferences implements IUserPreferences {
): array {
$this->assertParams($userId, $app, $prefix);
// if we want to filter values, we need to get sensitivity
- $this->loadPreferencesAll($userId);
- // array_merge() will remove numeric keys (here preference keys), so addition arrays instead
+ $this->loadConfigAll($userId);
+ // array_merge() will remove numeric keys (here config keys), so addition arrays instead
$values = array_filter(
$this->formatAppValues($userId, $app, ($this->fastCache[$userId][$app] ?? []) + ($this->lazyCache[$userId][$app] ?? []), $filtered),
function (string $key) use ($prefix): bool {
@@ -269,18 +269,18 @@ class UserPreferences implements IUserPreferences {
* @inheritDoc
*
* @param string $userId id of the user
- * @param bool $filtered TRUE to hide sensitive preference values. Value are replaced by {@see IConfig::SENSITIVE_VALUE}
+ * @param bool $filtered TRUE to hide sensitive config values. Value are replaced by {@see IConfig::SENSITIVE_VALUE}
*
* @return array<string, array<string, string|int|float|bool|array>> [appId => [key => value]]
* @since 31.0.0
*/
public function getAllValues(string $userId, bool $filtered = false): array {
$this->assertParams($userId, allowEmptyApp: true);
- $this->loadPreferencesAll($userId);
+ $this->loadConfigAll($userId);
$result = [];
foreach ($this->getApps($userId) as $app) {
- // array_merge() will remove numeric keys (here preference keys), so addition arrays instead
+ // array_merge() will remove numeric keys (here config keys), so addition arrays instead
$cached = ($this->fastCache[$userId][$app] ?? []) + ($this->lazyCache[$userId][$app] ?? []);
$result[$app] = $this->formatAppValues($userId, $app, $cached, $filtered);
}
@@ -292,8 +292,8 @@ class UserPreferences implements IUserPreferences {
* @inheritDoc
*
* @param string $userId id of the user
- * @param string $key preference key
- * @param bool $lazy search within lazy loaded preferences
+ * @param string $key config key
+ * @param bool $lazy search within lazy loaded config
* @param ValueType|null $typedAs enforce type for the returned values
*
* @return array<string, string|int|float|bool|array> [appId => value]
@@ -301,7 +301,7 @@ class UserPreferences implements IUserPreferences {
*/
public function getValuesByApps(string $userId, string $key, bool $lazy = false, ?ValueType $typedAs = null): array {
$this->assertParams($userId, '', $key, allowEmptyApp: true);
- $this->loadPreferences($userId, $lazy);
+ $this->loadConfig($userId, $lazy);
/** @var array<array-key, array<array-key, mixed>> $cache */
if ($lazy) {
@@ -331,7 +331,7 @@ class UserPreferences implements IUserPreferences {
* @inheritDoc
*
* @param string $app id of the app
- * @param string $key preference key
+ * @param string $key config key
* @param ValueType|null $typedAs enforce type for the returned values
* @param array|null $userIds limit to a list of user ids
*
@@ -390,8 +390,8 @@ class UserPreferences implements IUserPreferences {
* @inheritDoc
*
* @param string $app id of the app
- * @param string $key preference key
- * @param string $value preference value
+ * @param string $key config key
+ * @param string $value config value
* @param bool $caseInsensitive non-case-sensitive search, only works if $value is a string
*
* @return Generator<string>
@@ -405,8 +405,8 @@ class UserPreferences implements IUserPreferences {
* @inheritDoc
*
* @param string $app id of the app
- * @param string $key preference key
- * @param int $value preference value
+ * @param string $key config key
+ * @param int $value config value
*
* @return Generator<string>
* @since 31.0.0
@@ -419,8 +419,8 @@ class UserPreferences implements IUserPreferences {
* @inheritDoc
*
* @param string $app id of the app
- * @param string $key preference key
- * @param array $values list of preference values
+ * @param string $key config key
+ * @param array $values list of config values
*
* @return Generator<string>
* @since 31.0.0
@@ -433,8 +433,8 @@ class UserPreferences implements IUserPreferences {
* @inheritDoc
*
* @param string $app id of the app
- * @param string $key preference key
- * @param bool $value preference value
+ * @param string $key config key
+ * @param bool $value config value
*
* @return Generator<string>
* @since 31.0.0
@@ -448,7 +448,7 @@ class UserPreferences implements IUserPreferences {
}
/**
- * returns a list of users with preference key set to a specific value, or within the list of
+ * returns a list of users with config key set to a specific value, or within the list of
* possible values
*
* @param string $app
@@ -506,7 +506,7 @@ class UserPreferences implements IUserPreferences {
}
/**
- * Get the preference value as string.
+ * Get the config value as string.
* If the value does not exist the given default will be returned.
*
* Set lazy to `null` to ignore it and get the value from either source.
@@ -515,15 +515,15 @@ class UserPreferences implements IUserPreferences {
*
* @param string $userId id of the user
* @param string $app id of the app
- * @param string $key preference key
- * @param string $default preference value
- * @param null|bool $lazy get preference as lazy loaded or not. can be NULL
+ * @param string $key config key
+ * @param string $default config value
+ * @param null|bool $lazy get config as lazy loaded or not. can be NULL
*
* @return string the value or $default
* @throws TypeConflictException
* @internal
* @since 31.0.0
- * @see IUserPreferences for explanation about lazy loading
+ * @see IUserConfig for explanation about lazy loading
* @see getValueString()
* @see getValueInt()
* @see getValueFloat()
@@ -558,15 +558,15 @@ class UserPreferences implements IUserPreferences {
*
* @param string $userId id of the user
* @param string $app id of the app
- * @param string $key preference key
+ * @param string $key config key
* @param string $default default value
- * @param bool $lazy search within lazy loaded preferences
+ * @param bool $lazy search within lazy loaded config
*
- * @return string stored preference value or $default if not set in database
+ * @return string stored config value or $default if not set in database
* @throws InvalidArgumentException if one of the argument format is invalid
* @throws TypeConflictException in case of conflict with the value type set in database
* @since 31.0.0
- * @see IUserPreferences for explanation about lazy loading
+ * @see IUserConfig for explanation about lazy loading
*/
public function getValueString(
string $userId,
@@ -583,15 +583,15 @@ class UserPreferences implements IUserPreferences {
*
* @param string $userId id of the user
* @param string $app id of the app
- * @param string $key preference key
+ * @param string $key config key
* @param int $default default value
- * @param bool $lazy search within lazy loaded preferences
+ * @param bool $lazy search within lazy loaded config
*
- * @return int stored preference value or $default if not set in database
+ * @return int stored config value or $default if not set in database
* @throws InvalidArgumentException if one of the argument format is invalid
* @throws TypeConflictException in case of conflict with the value type set in database
* @since 31.0.0
- * @see IUserPreferences for explanation about lazy loading
+ * @see IUserConfig for explanation about lazy loading
*/
public function getValueInt(
string $userId,
@@ -608,15 +608,15 @@ class UserPreferences implements IUserPreferences {
*
* @param string $userId id of the user
* @param string $app id of the app
- * @param string $key preference key
+ * @param string $key config key
* @param float $default default value
- * @param bool $lazy search within lazy loaded preferences
+ * @param bool $lazy search within lazy loaded config
*
- * @return float stored preference value or $default if not set in database
+ * @return float stored config value or $default if not set in database
* @throws InvalidArgumentException if one of the argument format is invalid
* @throws TypeConflictException in case of conflict with the value type set in database
* @since 31.0.0
- * @see IUserPreferences for explanation about lazy loading
+ * @see IUserConfig for explanation about lazy loading
*/
public function getValueFloat(
string $userId,
@@ -633,15 +633,15 @@ class UserPreferences implements IUserPreferences {
*
* @param string $userId id of the user
* @param string $app id of the app
- * @param string $key preference key
+ * @param string $key config key
* @param bool $default default value
- * @param bool $lazy search within lazy loaded preferences
+ * @param bool $lazy search within lazy loaded config
*
- * @return bool stored preference value or $default if not set in database
+ * @return bool stored config value or $default if not set in database
* @throws InvalidArgumentException if one of the argument format is invalid
* @throws TypeConflictException in case of conflict with the value type set in database
* @since 31.0.0
- * @see IUserPreferences for explanation about lazy loading
+ * @see IUserConfig for explanation about lazy loading
*/
public function getValueBool(
string $userId,
@@ -659,15 +659,15 @@ class UserPreferences implements IUserPreferences {
*
* @param string $userId id of the user
* @param string $app id of the app
- * @param string $key preference key
+ * @param string $key config key
* @param array $default default value
- * @param bool $lazy search within lazy loaded preferences
+ * @param bool $lazy search within lazy loaded config
*
- * @return array stored preference value or $default if not set in database
+ * @return array stored config value or $default if not set in database
* @throws InvalidArgumentException if one of the argument format is invalid
* @throws TypeConflictException in case of conflict with the value type set in database
* @since 31.0.0
- * @see IUserPreferences for explanation about lazy loading
+ * @see IUserConfig for explanation about lazy loading
*/
public function getValueArray(
string $userId,
@@ -689,9 +689,9 @@ class UserPreferences implements IUserPreferences {
/**
* @param string $userId
* @param string $app id of the app
- * @param string $key preference key
+ * @param string $key config key
* @param string $default default value
- * @param bool $lazy search within lazy loaded preferences
+ * @param bool $lazy search within lazy loaded config
* @param ValueType $type value type
*
* @return string
@@ -706,7 +706,7 @@ class UserPreferences implements IUserPreferences {
ValueType $type,
): string {
$this->assertParams($userId, $app, $key);
- $this->loadPreferences($userId, $lazy);
+ $this->loadConfig($userId, $lazy);
/**
* We ignore check if mixed type is requested.
@@ -727,7 +727,7 @@ class UserPreferences implements IUserPreferences {
* - we should still return an existing non-lazy value even if current method
* is called with $lazy is true
*
- * This way, lazyCache will be empty until the load for lazy preferences value is requested.
+ * This way, lazyCache will be empty until the load for lazy config value is requested.
*/
if (isset($this->lazyCache[$userId][$app][$key])) {
$value = $this->lazyCache[$userId][$app][$key];
@@ -746,19 +746,19 @@ class UserPreferences implements IUserPreferences {
*
* @param string $userId id of the user
* @param string $app id of the app
- * @param string $key preference key
+ * @param string $key config key
*
* @return ValueType type of the value
- * @throws UnknownKeyException if preference key is not known
- * @throws IncorrectTypeException if preferences value type is not known
+ * @throws UnknownKeyException if config key is not known
+ * @throws IncorrectTypeException if config value type is not known
* @since 31.0.0
*/
public function getValueType(string $userId, string $app, string $key, ?bool $lazy = null): ValueType {
$this->assertParams($userId, $app, $key);
- $this->loadPreferences($userId, $lazy);
+ $this->loadConfig($userId, $lazy);
if (!isset($this->valueDetails[$userId][$app][$key]['type'])) {
- throw new UnknownKeyException('unknown preference key');
+ throw new UnknownKeyException('unknown config key');
}
return $this->valueDetails[$userId][$app][$key]['type'];
@@ -769,42 +769,42 @@ class UserPreferences implements IUserPreferences {
*
* @param string $userId id of the user
* @param string $app id of the app
- * @param string $key preference key
+ * @param string $key config key
* @param bool $lazy lazy loading
*
* @return int flags applied to value
- * @throws UnknownKeyException if preference key is not known
- * @throws IncorrectTypeException if preferences value type is not known
+ * @throws UnknownKeyException if config key is not known
+ * @throws IncorrectTypeException if config value type is not known
* @since 31.0.0
*/
public function getValueFlags(string $userId, string $app, string $key, bool $lazy = false): int {
$this->assertParams($userId, $app, $key);
- $this->loadPreferences($userId, $lazy);
+ $this->loadConfig($userId, $lazy);
if (!isset($this->valueDetails[$userId][$app][$key])) {
- throw new UnknownKeyException('unknown preference key');
+ throw new UnknownKeyException('unknown config key');
}
return $this->valueDetails[$userId][$app][$key]['flags'];
}
/**
- * Store a preference key and its value in database as VALUE_MIXED
+ * Store a config key and its value in database as VALUE_MIXED
*
* **WARNING:** Method is internal and **MUST** not be used as it is best to set a real value type
*
* @param string $userId id of the user
* @param string $app id of the app
- * @param string $key preference key
- * @param string $value preference value
- * @param bool $lazy set preference as lazy loaded
- * @param bool $sensitive if TRUE value will be hidden when listing preference values.
+ * @param string $key config key
+ * @param string $value config value
+ * @param bool $lazy set config as lazy loaded
+ * @param bool $sensitive if TRUE value will be hidden when listing config values.
*
* @return bool TRUE if value was different, therefor updated in database
* @throws TypeConflictException if type from database is not VALUE_MIXED
* @internal
* @since 31.0.0
- * @see IUserPreferences for explanation about lazy loading
+ * @see IUserConfig for explanation about lazy loading
* @see setValueString()
* @see setValueInt()
* @see setValueFloat()
@@ -836,15 +836,15 @@ class UserPreferences implements IUserPreferences {
*
* @param string $userId id of the user
* @param string $app id of the app
- * @param string $key preference key
- * @param string $value preference value
- * @param bool $lazy set preference as lazy loaded
- * @param bool $sensitive if TRUE value will be hidden when listing preference values.
+ * @param string $key config key
+ * @param string $value config value
+ * @param bool $lazy set config as lazy loaded
+ * @param bool $sensitive if TRUE value will be hidden when listing config values.
*
* @return bool TRUE if value was different, therefor updated in database
* @throws TypeConflictException if type from database is not VALUE_MIXED and different from the requested one
* @since 31.0.0
- * @see IUserPreferences for explanation about lazy loading
+ * @see IUserConfig for explanation about lazy loading
*/
public function setValueString(
string $userId,
@@ -870,15 +870,15 @@ class UserPreferences implements IUserPreferences {
*
* @param string $userId id of the user
* @param string $app id of the app
- * @param string $key preference key
- * @param int $value preference value
- * @param bool $lazy set preference as lazy loaded
- * @param bool $sensitive if TRUE value will be hidden when listing preference values.
+ * @param string $key config key
+ * @param int $value config value
+ * @param bool $lazy set config as lazy loaded
+ * @param bool $sensitive if TRUE value will be hidden when listing config values.
*
* @return bool TRUE if value was different, therefor updated in database
* @throws TypeConflictException if type from database is not VALUE_MIXED and different from the requested one
* @since 31.0.0
- * @see IUserPreferences for explanation about lazy loading
+ * @see IUserConfig for explanation about lazy loading
*/
public function setValueInt(
string $userId,
@@ -908,15 +908,15 @@ class UserPreferences implements IUserPreferences {
*
* @param string $userId id of the user
* @param string $app id of the app
- * @param string $key preference key
- * @param float $value preference value
- * @param bool $lazy set preference as lazy loaded
- * @param bool $sensitive if TRUE value will be hidden when listing preference values.
+ * @param string $key config key
+ * @param float $value config value
+ * @param bool $lazy set config as lazy loaded
+ * @param bool $sensitive if TRUE value will be hidden when listing config values.
*
* @return bool TRUE if value was different, therefor updated in database
* @throws TypeConflictException if type from database is not VALUE_MIXED and different from the requested one
* @since 31.0.0
- * @see IUserPreferences for explanation about lazy loading
+ * @see IUserConfig for explanation about lazy loading
*/
public function setValueFloat(
string $userId,
@@ -942,14 +942,14 @@ class UserPreferences implements IUserPreferences {
*
* @param string $userId id of the user
* @param string $app id of the app
- * @param string $key preference key
- * @param bool $value preference value
- * @param bool $lazy set preference as lazy loaded
+ * @param string $key config key
+ * @param bool $value config value
+ * @param bool $lazy set config as lazy loaded
*
* @return bool TRUE if value was different, therefor updated in database
* @throws TypeConflictException if type from database is not VALUE_MIXED and different from the requested one
* @since 31.0.0
- * @see IUserPreferences for explanation about lazy loading
+ * @see IUserConfig for explanation about lazy loading
*/
public function setValueBool(
string $userId,
@@ -975,16 +975,16 @@ class UserPreferences implements IUserPreferences {
*
* @param string $userId id of the user
* @param string $app id of the app
- * @param string $key preference key
- * @param array $value preference value
- * @param bool $lazy set preference as lazy loaded
- * @param bool $sensitive if TRUE value will be hidden when listing preference values.
+ * @param string $key config key
+ * @param array $value config value
+ * @param bool $lazy set config as lazy loaded
+ * @param bool $sensitive if TRUE value will be hidden when listing config values.
*
* @return bool TRUE if value was different, therefor updated in database
* @throws TypeConflictException if type from database is not VALUE_MIXED and different from the requested one
* @throws JsonException
* @since 31.0.0
- * @see IUserPreferences for explanation about lazy loading
+ * @see IUserConfig for explanation about lazy loading
*/
public function setValueArray(
string $userId,
@@ -1011,22 +1011,22 @@ class UserPreferences implements IUserPreferences {
}
/**
- * Store a preference key and its value in database
+ * Store a config key and its value in database
*
- * If preference key is already known with the exact same preference value and same sensitive/lazy status, the
- * database is not updated. If preference value was previously stored as sensitive, status will not be
+ * If config key is already known with the exact same config value and same sensitive/lazy status, the
+ * database is not updated. If config value was previously stored as sensitive, status will not be
* altered.
*
* @param string $userId id of the user
* @param string $app id of the app
- * @param string $key preference key
- * @param string $value preference value
- * @param bool $lazy preferences set as lazy loaded
+ * @param string $key config key
+ * @param string $value config value
+ * @param bool $lazy config set as lazy loaded
* @param ValueType $type value type
*
* @return bool TRUE if value was updated in database
* @throws TypeConflictException if type from database is not VALUE_MIXED and different from the requested one
- * @see IUserPreferences for explanation about lazy loading
+ * @see IUserConfig for explanation about lazy loading
*/
private function setTypedValue(
string $userId,
@@ -1038,14 +1038,14 @@ class UserPreferences implements IUserPreferences {
ValueType $type,
): bool {
$this->assertParams($userId, $app, $key);
- $this->loadPreferences($userId, $lazy);
+ $this->loadConfig($userId, $lazy);
$inserted = $refreshCache = false;
$origValue = $value;
$sensitive = $this->isFlagged(self::FLAG_SENSITIVE, $flags);
if ($sensitive || ($this->hasKey($userId, $app, $key, $lazy) && $this->isSensitive($userId, $app, $key, $lazy))) {
$value = self::ENCRYPTION_PREFIX . $this->crypto->encrypt($value);
- $flags |= UserPreferences::FLAG_SENSITIVE;
+ $flags |= UserConfig::FLAG_SENSITIVE;
}
// if requested, we fill the 'indexed' field with current value
@@ -1100,7 +1100,7 @@ class UserPreferences implements IUserPreferences {
if (!$inserted) {
$currType = $this->valueDetails[$userId][$app][$key]['type'] ?? null;
if ($currType === null) { // this might happen when switching lazy loading status
- $this->loadPreferencesAll($userId);
+ $this->loadConfigAll($userId);
$currType = $this->valueDetails[$userId][$app][$key]['type'];
}
@@ -1166,13 +1166,13 @@ class UserPreferences implements IUserPreferences {
}
/**
- * Change the type of preference value.
+ * Change the type of config value.
*
* **WARNING:** Method is internal and **MUST** not be used as it may break things.
*
* @param string $userId id of the user
* @param string $app id of the app
- * @param string $key preference key
+ * @param string $key config key
* @param ValueType $type value type
*
* @return bool TRUE if database update were necessary
@@ -1183,7 +1183,7 @@ class UserPreferences implements IUserPreferences {
*/
public function updateType(string $userId, string $app, string $key, ValueType $type = ValueType::MIXED): bool {
$this->assertParams($userId, $app, $key);
- $this->loadPreferencesAll($userId);
+ $this->loadConfigAll($userId);
$this->isLazy($userId, $app, $key); // confirm key exists
$update = $this->connection->getQueryBuilder();
@@ -1204,7 +1204,7 @@ class UserPreferences implements IUserPreferences {
*
* @param string $userId id of the user
* @param string $app id of the app
- * @param string $key preference key
+ * @param string $key config key
* @param bool $sensitive TRUE to set as sensitive, FALSE to unset
*
* @return bool TRUE if entry was found in database and an update was necessary
@@ -1212,7 +1212,7 @@ class UserPreferences implements IUserPreferences {
*/
public function updateSensitive(string $userId, string $app, string $key, bool $sensitive): bool {
$this->assertParams($userId, $app, $key);
- $this->loadPreferencesAll($userId);
+ $this->loadConfigAll($userId);
try {
if ($sensitive === $this->isSensitive($userId, $app, $key, null)) {
@@ -1230,7 +1230,7 @@ class UserPreferences implements IUserPreferences {
}
if (!isset($cache[$userId][$app][$key])) {
- throw new UnknownKeyException('unknown preference key');
+ throw new UnknownKeyException('unknown config key');
}
$value = $cache[$userId][$app][$key];
@@ -1295,7 +1295,7 @@ class UserPreferences implements IUserPreferences {
*/
public function updateIndexed(string $userId, string $app, string $key, bool $indexed): bool {
$this->assertParams($userId, $app, $key);
- $this->loadPreferencesAll($userId);
+ $this->loadConfigAll($userId);
try {
if ($indexed === $this->isIndexed($userId, $app, $key, null)) {
@@ -1313,7 +1313,7 @@ class UserPreferences implements IUserPreferences {
}
if (!isset($cache[$userId][$app][$key])) {
- throw new UnknownKeyException('unknown preference key');
+ throw new UnknownKeyException('unknown config key');
}
$value = $cache[$userId][$app][$key];
@@ -1367,7 +1367,7 @@ class UserPreferences implements IUserPreferences {
*
* @param string $userId id of the user
* @param string $app id of the app
- * @param string $key preference key
+ * @param string $key config key
* @param bool $lazy TRUE to set as lazy loaded, FALSE to unset
*
* @return bool TRUE if entry was found in database and an update was necessary
@@ -1375,7 +1375,7 @@ class UserPreferences implements IUserPreferences {
*/
public function updateLazy(string $userId, string $app, string $key, bool $lazy): bool {
$this->assertParams($userId, $app, $key);
- $this->loadPreferencesAll($userId);
+ $this->loadConfigAll($userId);
try {
if ($lazy === $this->isLazy($userId, $app, $key)) {
@@ -1403,7 +1403,7 @@ class UserPreferences implements IUserPreferences {
* @inheritDoc
*
* @param string $app id of the app
- * @param string $key preference key
+ * @param string $key config key
* @param bool $lazy TRUE to set as lazy loaded, FALSE to unset
*
* @since 31.0.0
@@ -1426,15 +1426,15 @@ class UserPreferences implements IUserPreferences {
*
* @param string $userId id of the user
* @param string $app id of the app
- * @param string $key preference key
+ * @param string $key config key
*
* @return array
- * @throws UnknownKeyException if preference key is not known in database
+ * @throws UnknownKeyException if config key is not known in database
* @since 31.0.0
*/
public function getDetails(string $userId, string $app, string $key): array {
$this->assertParams($userId, $app, $key);
- $this->loadPreferencesAll($userId);
+ $this->loadConfigAll($userId);
$lazy = $this->isLazy($userId, $app, $key);
if ($lazy) {
@@ -1452,7 +1452,7 @@ class UserPreferences implements IUserPreferences {
}
if (!isset($cache[$app][$key])) {
- throw new UnknownKeyException('unknown preference key');
+ throw new UnknownKeyException('unknown config key');
}
$value = $cache[$app][$key];
@@ -1476,11 +1476,11 @@ class UserPreferences implements IUserPreferences {
*
* @param string $userId id of the user
* @param string $app id of the app
- * @param string $key preference key
+ * @param string $key config key
*
* @since 31.0.0
*/
- public function deletePreference(string $userId, string $app, string $key): void {
+ public function deleteUserConfig(string $userId, string $app, string $key): void {
$this->assertParams($userId, $app, $key);
$qb = $this->connection->getQueryBuilder();
$qb->delete('preferences')
@@ -1497,7 +1497,7 @@ class UserPreferences implements IUserPreferences {
* @inheritDoc
*
* @param string $app id of the app
- * @param string $key preference key
+ * @param string $key config key
*
* @since 31.0.0
*/
@@ -1529,7 +1529,7 @@ class UserPreferences implements IUserPreferences {
$this->clearCacheAll();
}
- public function deleteAllPreferences(string $userId): void {
+ public function deleteAllUserConfig(string $userId): void {
$this->assertParams($userId, '', allowEmptyApp: true);
$qb = $this->connection->getQueryBuilder();
$qb->delete('preferences')
@@ -1556,7 +1556,7 @@ class UserPreferences implements IUserPreferences {
return;
}
- $this->loadPreferencesAll($userId);
+ $this->loadConfigAll($userId);
}
/**
@@ -1602,7 +1602,7 @@ class UserPreferences implements IUserPreferences {
*
* @param string $userId
* @param string $app assert $app fit in database
- * @param string $prefKey assert preference key fit in database
+ * @param string $prefKey assert config key fit in database
* @param bool $allowEmptyUser
* @param bool $allowEmptyApp $app can be empty string
* @param ValueType|null $valueType assert value type is only one type
@@ -1631,22 +1631,22 @@ class UserPreferences implements IUserPreferences {
}
}
- private function loadPreferencesAll(string $userId): void {
- $this->loadPreferences($userId, null);
+ private function loadConfigAll(string $userId): void {
+ $this->loadConfig($userId, null);
}
/**
- * Load normal preferences or preferences set as lazy loaded
+ * Load normal config or config set as lazy loaded
*
- * @param bool|null $lazy set to TRUE to load preferences set as lazy loaded, set to NULL to load all preferences
+ * @param bool|null $lazy set to TRUE to load config set as lazy loaded, set to NULL to load all config
*/
- private function loadPreferences(string $userId, ?bool $lazy = false): void {
+ private function loadConfig(string $userId, ?bool $lazy = false): void {
if ($this->isLoaded($userId, $lazy)) {
return;
}
if (($lazy ?? true) !== false) { // if lazy is null or true, we debug log
- $this->logger->debug('The loading of lazy UserPreferences values have been requested', ['exception' => new \RuntimeException('ignorable exception')]);
+ $this->logger->debug('The loading of lazy UserConfig values have been requested', ['exception' => new \RuntimeException('ignorable exception')]);
}
$qb = $this->connection->getQueryBuilder();
@@ -1654,7 +1654,7 @@ class UserPreferences implements IUserPreferences {
$qb->select('appid', 'configkey', 'configvalue', 'type', 'flags');
$qb->where($qb->expr()->eq('userid', $qb->createNamedParameter($userId)));
- // we only need value from lazy when loadPreferences does not specify it
+ // we only need value from lazy when loadConfig does not specify it
if ($lazy !== null) {
$qb->andWhere($qb->expr()->eq('lazy', $qb->createNamedParameter($lazy ? 1 : 0, IQueryBuilder::PARAM_INT)));
} else {
@@ -1677,9 +1677,9 @@ class UserPreferences implements IUserPreferences {
/**
* if $lazy is:
- * - false: will returns true if fast preferences are loaded
- * - true : will returns true if lazy preferences are loaded
- * - null : will returns true if both preferences are loaded
+ * - false: will returns true if fast config are loaded
+ * - true : will returns true if lazy config are loaded
+ * - null : will returns true if both config are loaded
*
* @param string $userId
* @param bool $lazy
@@ -1696,9 +1696,9 @@ class UserPreferences implements IUserPreferences {
/**
* if $lazy is:
- * - false: set fast preferences as loaded
- * - true : set lazy preferences as loaded
- * - null : set both preferences as loaded
+ * - false: set fast config as loaded
+ * - true : set lazy config as loaded
+ * - null : set both config as loaded
*
* @param string $userId
* @param bool $lazy
@@ -1726,7 +1726,7 @@ class UserPreferences implements IUserPreferences {
*
* @param string $userId id of the user
* @param string $app id of the app
- * @param bool $filtered TRUE to hide sensitive preference values. Value are replaced by {@see IConfig::SENSITIVE_VALUE}
+ * @param bool $filtered TRUE to hide sensitive config values. Value are replaced by {@see IConfig::SENSITIVE_VALUE}
*
* @return array<string, string|int|float|bool|array>
*/
diff --git a/lib/private/Server.php b/lib/private/Server.php
index dc4b3c4f7dc..d57ddf61c03 100644
--- a/lib/private/Server.php
+++ b/lib/private/Server.php
@@ -7,7 +7,7 @@
namespace OC;
use bantu\IniGetWrapper\IniGetWrapper;
-use NCU\Config\IUserPreferences;
+use NCU\Config\IUserConfig;
use OC\Accounts\AccountManager;
use OC\App\AppManager;
use OC\App\AppStore\Bundles\BundleFetcher;
@@ -568,7 +568,7 @@ class Server extends ServerContainer implements IServerContainer {
});
$this->registerAlias(IAppConfig::class, \OC\AppConfig::class);
- $this->registerAlias(IUserPreferences::class, \OC\Config\UserPreferences::class);
+ $this->registerAlias(IUserConfig::class, \OC\Config\UserConfig::class);
$this->registerService(IFactory::class, function (Server $c) {
return new \OC\L10N\Factory(
diff --git a/lib/public/IConfig.php b/lib/public/IConfig.php
index f434f838d45..3bc64c5e133 100644
--- a/lib/public/IConfig.php
+++ b/lib/public/IConfig.php
@@ -245,7 +245,7 @@ interface IConfig {
* @param string $appName the app to get the user for
* @param string $key the key to get the user for
* @param string $value the value to get the user for
- * @return array<string> of user IDs
+ * @return list<string> of user IDs
* @since 31.0.0 return type of `list<string>`
* @since 8.0.0
*/
diff --git a/lib/unstable/Config/Exceptions/IncorrectTypeException.php b/lib/unstable/Config/Exceptions/IncorrectTypeException.php
index b3eedde5300..a5e4954cdb2 100644
--- a/lib/unstable/Config/Exceptions/IncorrectTypeException.php
+++ b/lib/unstable/Config/Exceptions/IncorrectTypeException.php
@@ -11,6 +11,7 @@ namespace NCU\Config\Exceptions;
use Exception;
/**
+ * @experimental 31.0.0
* @since 31.0.0
*/
class IncorrectTypeException extends Exception {
diff --git a/lib/unstable/Config/Exceptions/TypeConflictException.php b/lib/unstable/Config/Exceptions/TypeConflictException.php
index 042991f8a57..c192b2c4f9d 100644
--- a/lib/unstable/Config/Exceptions/TypeConflictException.php
+++ b/lib/unstable/Config/Exceptions/TypeConflictException.php
@@ -11,6 +11,7 @@ namespace NCU\Config\Exceptions;
use Exception;
/**
+ * @experimental 31.0.0
* @since 31.0.0
*/
class TypeConflictException extends Exception {
diff --git a/lib/unstable/Config/Exceptions/UnknownKeyException.php b/lib/unstable/Config/Exceptions/UnknownKeyException.php
index 80626c6a635..5f83800cafc 100644
--- a/lib/unstable/Config/Exceptions/UnknownKeyException.php
+++ b/lib/unstable/Config/Exceptions/UnknownKeyException.php
@@ -11,6 +11,7 @@ namespace NCU\Config\Exceptions;
use Exception;
/**
+ * @experimental 31.0.0
* @since 31.0.0
*/
class UnknownKeyException extends Exception {
diff --git a/lib/unstable/Config/IUserPreferences.php b/lib/unstable/Config/IUserConfig.php
index a2695a0d053..21e5b6fb014 100644
--- a/lib/unstable/Config/IUserPreferences.php
+++ b/lib/unstable/Config/IUserConfig.php
@@ -13,12 +13,12 @@ use NCU\Config\Exceptions\IncorrectTypeException;
use NCU\Config\Exceptions\UnknownKeyException;
/**
- * This class provides an easy way for apps to store user preferences in the
+ * This class provides an easy way for apps to store user config in the
* database.
* Supports **lazy loading**
*
* ### What is lazy loading ?
- * In order to avoid loading useless user preferences into memory for each request,
+ * In order to avoid loading useless user config into memory for each request,
* only non-lazy values are now loaded.
*
* Once a value that is lazy is requested, all lazy values will be loaded.
@@ -27,17 +27,17 @@ use NCU\Config\Exceptions\UnknownKeyException;
* lazy loading. Use them wisely and only on parts of the code that are called
* during specific requests or actions to avoid loading the lazy values all the time.
*
+ * @experimental 31.0.0
* @since 31.0.0
*/
-
-interface IUserPreferences {
+interface IUserConfig {
/** @since 31.0.0 */
public const FLAG_SENSITIVE = 1; // value is sensitive
/** @since 31.0.0 */
public const FLAG_INDEXED = 2; // value should be indexed
/**
- * Get list of all userIds with preferences stored in database.
+ * Get list of all userIds with config stored in database.
* If $appId is specified, will only limit the search to this value
*
* **WARNING:** ignore any cache and get data directly from database.
@@ -50,10 +50,10 @@ interface IUserPreferences {
public function getUserIds(string $appId = ''): array;
/**
- * Get list of all apps that have at least one preference
+ * Get list of all apps that have at least one config
* value related to $userId stored in database
*
- * **WARNING:** ignore lazy filtering, all user preferences are loaded from database
+ * **WARNING:** ignore lazy filtering, all user config are loaded from database
*
* @param string $userId id of the user
*
@@ -66,23 +66,23 @@ interface IUserPreferences {
* Returns all keys stored in database, related to user+app.
* Please note that the values are not returned.
*
- * **WARNING:** ignore lazy filtering, all user preferences are loaded from database
+ * **WARNING:** ignore lazy filtering, all user config are loaded from database
*
* @param string $userId id of the user
* @param string $app id of the app
*
- * @return list<string> list of stored preference keys
+ * @return list<string> list of stored config keys
* @since 31.0.0
*/
public function getKeys(string $userId, string $app): array;
/**
- * Check if a key exists in the list of stored preference values.
+ * Check if a key exists in the list of stored config values.
*
* @param string $userId id of the user
* @param string $app id of the app
- * @param string $key preference key
- * @param bool $lazy search within lazy loaded preferences
+ * @param string $key config key
+ * @param bool $lazy search within lazy loaded config
*
* @return bool TRUE if key exists
* @since 31.0.0
@@ -94,11 +94,11 @@ interface IUserPreferences {
*
* @param string $userId id of the user
* @param string $app id of the app
- * @param string $key preference key
- * @param bool|null $lazy search within lazy loaded preferences
+ * @param string $key config key
+ * @param bool|null $lazy search within lazy loaded config
*
* @return bool TRUE if value is sensitive
- * @throws UnknownKeyException if preference key is not known
+ * @throws UnknownKeyException if config key is not known
* @since 31.0.0
*/
public function isSensitive(string $userId, string $app, string $key, ?bool $lazy = false): bool;
@@ -113,41 +113,41 @@ interface IUserPreferences {
*
* @param string $userId id of the user
* @param string $app id of the app
- * @param string $key preference key
- * @param bool|null $lazy search within lazy loaded preferences
+ * @param string $key config key
+ * @param bool|null $lazy search within lazy loaded config
*
* @return bool TRUE if value is sensitive
- * @throws UnknownKeyException if preference key is not known
+ * @throws UnknownKeyException if config key is not known
* @since 31.0.0
*/
public function isIndexed(string $userId, string $app, string $key, ?bool $lazy = false): bool;
/**
- * Returns if the preference key stored in database is lazy loaded
+ * Returns if the config key stored in database is lazy loaded
*
- * **WARNING:** ignore lazy filtering, all preference values are loaded from database
+ * **WARNING:** ignore lazy filtering, all config values are loaded from database
*
* @param string $userId id of the user
* @param string $app id of the app
- * @param string $key preference key
+ * @param string $key config key
*
- * @return bool TRUE if preference is lazy loaded
- * @throws UnknownKeyException if preference key is not known
- * @see IUserPreferences for details about lazy loading
+ * @return bool TRUE if config is lazy loaded
+ * @throws UnknownKeyException if config key is not known
+ * @see IUserConfig for details about lazy loading
* @since 31.0.0
*/
public function isLazy(string $userId, string $app, string $key): bool;
/**
- * List all preference values from an app with preference key starting with $key.
- * Returns an array with preference key as key, stored value as value.
+ * List all config values from an app with config key starting with $key.
+ * Returns an array with config key as key, stored value as value.
*
- * **WARNING:** ignore lazy filtering, all preference values are loaded from database
+ * **WARNING:** ignore lazy filtering, all config values are loaded from database
*
* @param string $userId id of the user
* @param string $app id of the app
- * @param string $prefix preference keys prefix to search, can be empty.
- * @param bool $filtered filter sensitive preference values
+ * @param string $prefix config keys prefix to search, can be empty.
+ * @param bool $filtered filter sensitive config values
*
* @return array<string, string|int|float|bool|array> [key => value]
* @since 31.0.0
@@ -155,13 +155,13 @@ interface IUserPreferences {
public function getValues(string $userId, string $app, string $prefix = '', bool $filtered = false): array;
/**
- * List all preference values of a user.
- * Returns an array with preference key as key, stored value as value.
+ * List all config values of a user.
+ * Returns an array with config key as key, stored value as value.
*
- * **WARNING:** ignore lazy filtering, all preference values are loaded from database
+ * **WARNING:** ignore lazy filtering, all config values are loaded from database
*
* @param string $userId id of the user
- * @param bool $filtered filter sensitive preference values
+ * @param bool $filtered filter sensitive config values
*
* @return array<string, string|int|float|bool|array> [key => value]
* @since 31.0.0
@@ -169,12 +169,12 @@ interface IUserPreferences {
public function getAllValues(string $userId, bool $filtered = false): array;
/**
- * List all apps storing a specific preference key and its stored value.
+ * List all apps storing a specific config key and its stored value.
* Returns an array with appId as key, stored value as value.
*
* @param string $userId id of the user
- * @param string $key preference key
- * @param bool $lazy search within lazy loaded preferences
+ * @param string $key config key
+ * @param bool $lazy search within lazy loaded config
* @param ValueType|null $typedAs enforce type for the returned values
*
* @return array<string, string|int|float|bool|array> [appId => value]
@@ -183,13 +183,13 @@ interface IUserPreferences {
public function getValuesByApps(string $userId, string $key, bool $lazy = false, ?ValueType $typedAs = null): array;
/**
- * List all users storing a specific preference key and its stored value.
+ * List all users storing a specific config key and its stored value.
* Returns an array with userId as key, stored value as value.
*
* **WARNING:** no caching, generate a fresh request
*
* @param string $app id of the app
- * @param string $key preference key
+ * @param string $key config key
* @param ValueType|null $typedAs enforce type for the returned values
* @param array|null $userIds limit the search to a list of user ids
*
@@ -199,14 +199,14 @@ interface IUserPreferences {
public function getValuesByUsers(string $app, string $key, ?ValueType $typedAs = null, ?array $userIds = null): array;
/**
- * List all users storing a specific preference key/value pair.
+ * List all users storing a specific config key/value pair.
* Returns a list of user ids.
*
* **WARNING:** no caching, generate a fresh request
*
* @param string $app id of the app
- * @param string $key preference key
- * @param string $value preference value
+ * @param string $key config key
+ * @param string $value config value
* @param bool $caseInsensitive non-case-sensitive search, only works if $value is a string
*
* @return Generator<string>
@@ -215,14 +215,14 @@ interface IUserPreferences {
public function searchUsersByValueString(string $app, string $key, string $value, bool $caseInsensitive = false): Generator;
/**
- * List all users storing a specific preference key/value pair.
+ * List all users storing a specific config key/value pair.
* Returns a list of user ids.
*
* **WARNING:** no caching, generate a fresh request
*
* @param string $app id of the app
- * @param string $key preference key
- * @param int $value preference value
+ * @param string $key config key
+ * @param int $value config value
*
* @return Generator<string>
* @since 31.0.0
@@ -230,14 +230,14 @@ interface IUserPreferences {
public function searchUsersByValueInt(string $app, string $key, int $value): Generator;
/**
- * List all users storing a specific preference key/value pair.
+ * List all users storing a specific config key/value pair.
* Returns a list of user ids.
*
* **WARNING:** no caching, generate a fresh request
*
* @param string $app id of the app
- * @param string $key preference key
- * @param array $values list of possible preference values
+ * @param string $key config key
+ * @param array $values list of possible config values
*
* @return Generator<string>
* @since 31.0.0
@@ -245,14 +245,14 @@ interface IUserPreferences {
public function searchUsersByValues(string $app, string $key, array $values): Generator;
/**
- * List all users storing a specific preference key/value pair.
+ * List all users storing a specific config key/value pair.
* Returns a list of user ids.
*
* **WARNING:** no caching, generate a fresh request
*
* @param string $app id of the app
- * @param string $key preference key
- * @param bool $value preference value
+ * @param string $key config key
+ * @param bool $value config value
*
* @return Generator<string>
* @since 31.0.0
@@ -260,19 +260,19 @@ interface IUserPreferences {
public function searchUsersByValueBool(string $app, string $key, bool $value): Generator;
/**
- * Get user preference assigned to a preference key.
- * If preference key is not found in database, default value is returned.
- * If preference key is set as lazy loaded, the $lazy argument needs to be set to TRUE.
+ * Get user config assigned to a config key.
+ * If config key is not found in database, default value is returned.
+ * If config key is set as lazy loaded, the $lazy argument needs to be set to TRUE.
*
* @param string $userId id of the user
* @param string $app id of the app
- * @param string $key preference key
+ * @param string $key config key
* @param string $default default value
- * @param bool $lazy search within lazy loaded preferences
+ * @param bool $lazy search within lazy loaded config
*
- * @return string stored preference value or $default if not set in database
+ * @return string stored config value or $default if not set in database
* @since 31.0.0
- * @see IUserPreferences for explanation about lazy loading
+ * @see IUserConfig for explanation about lazy loading
* @see getValueInt()
* @see getValueFloat()
* @see getValueBool()
@@ -281,19 +281,19 @@ interface IUserPreferences {
public function getValueString(string $userId, string $app, string $key, string $default = '', bool $lazy = false): string;
/**
- * Get preference value assigned to a preference key.
- * If preference key is not found in database, default value is returned.
- * If preference key is set as lazy loaded, the $lazy argument needs to be set to TRUE.
+ * Get config value assigned to a config key.
+ * If config key is not found in database, default value is returned.
+ * If config key is set as lazy loaded, the $lazy argument needs to be set to TRUE.
*
* @param string $userId id of the user
* @param string $app id of the app
- * @param string $key preference key
+ * @param string $key config key
* @param int $default default value
- * @param bool $lazy search within lazy loaded preferences
+ * @param bool $lazy search within lazy loaded config
*
- * @return int stored preference value or $default if not set in database
+ * @return int stored config value or $default if not set in database
* @since 31.0.0
- * @see IUserPreferences for explanation about lazy loading
+ * @see IUserConfig for explanation about lazy loading
* @see getValueString()
* @see getValueFloat()
* @see getValueBool()
@@ -302,19 +302,19 @@ interface IUserPreferences {
public function getValueInt(string $userId, string $app, string $key, int $default = 0, bool $lazy = false): int;
/**
- * Get preference value assigned to a preference key.
- * If preference key is not found in database, default value is returned.
- * If preference key is set as lazy loaded, the $lazy argument needs to be set to TRUE.
+ * Get config value assigned to a config key.
+ * If config key is not found in database, default value is returned.
+ * If config key is set as lazy loaded, the $lazy argument needs to be set to TRUE.
*
* @param string $userId id of the user
* @param string $app id of the app
- * @param string $key preference key
+ * @param string $key config key
* @param float $default default value
- * @param bool $lazy search within lazy loaded preferences
+ * @param bool $lazy search within lazy loaded config
*
- * @return float stored preference value or $default if not set in database
+ * @return float stored config value or $default if not set in database
* @since 31.0.0
- * @see IUserPreferences for explanation about lazy loading
+ * @see IUserConfig for explanation about lazy loading
* @see getValueString()
* @see getValueInt()
* @see getValueBool()
@@ -323,17 +323,17 @@ interface IUserPreferences {
public function getValueFloat(string $userId, string $app, string $key, float $default = 0, bool $lazy = false): float;
/**
- * Get preference value assigned to a preference key.
- * If preference key is not found in database, default value is returned.
- * If preference key is set as lazy loaded, the $lazy argument needs to be set to TRUE.
+ * Get config value assigned to a config key.
+ * If config key is not found in database, default value is returned.
+ * If config key is set as lazy loaded, the $lazy argument needs to be set to TRUE.
*
* @param string $userId id of the user
* @param string $app id of the app
- * @param string $key preference key
+ * @param string $key config key
* @param bool $default default value
- * @param bool $lazy search within lazy loaded preferences
+ * @param bool $lazy search within lazy loaded config
*
- * @return bool stored preference value or $default if not set in database
+ * @return bool stored config value or $default if not set in database
* @since 31.0.0
* @see IUserPrefences for explanation about lazy loading
* @see getValueString()
@@ -344,19 +344,19 @@ interface IUserPreferences {
public function getValueBool(string $userId, string $app, string $key, bool $default = false, bool $lazy = false): bool;
/**
- * Get preference value assigned to a preference key.
- * If preference key is not found in database, default value is returned.
- * If preference key is set as lazy loaded, the $lazy argument needs to be set to TRUE.
+ * Get config value assigned to a config key.
+ * If config key is not found in database, default value is returned.
+ * If config key is set as lazy loaded, the $lazy argument needs to be set to TRUE.
*
* @param string $userId id of the user
* @param string $app id of the app
- * @param string $key preference key
+ * @param string $key config key
* @param array $default default value`
- * @param bool $lazy search within lazy loaded preferences
+ * @param bool $lazy search within lazy loaded config
*
- * @return array stored preference value or $default if not set in database
+ * @return array stored config value or $default if not set in database
* @since 31.0.0
- * @see IUserPreferences for explanation about lazy loading
+ * @see IUserConfig for explanation about lazy loading
* @see getValueString()
* @see getValueInt()
* @see getValueFloat()
@@ -365,59 +365,59 @@ interface IUserPreferences {
public function getValueArray(string $userId, string $app, string $key, array $default = [], bool $lazy = false): array;
/**
- * returns the type of preference value
+ * returns the type of config value
*
- * **WARNING:** ignore lazy filtering, all preference values are loaded from database
+ * **WARNING:** ignore lazy filtering, all config values are loaded from database
* unless lazy is set to false
*
* @param string $userId id of the user
* @param string $app id of the app
- * @param string $key preference key
+ * @param string $key config key
* @param bool|null $lazy
*
* @return ValueType type of the value
- * @throws UnknownKeyException if preference key is not known
- * @throws IncorrectTypeException if preferences value type is not known
+ * @throws UnknownKeyException if config key is not known
+ * @throws IncorrectTypeException if config value type is not known
* @since 31.0.0
*/
public function getValueType(string $userId, string $app, string $key, ?bool $lazy = null): ValueType;
/**
- * returns a bitflag related to preference value
+ * returns a bitflag related to config value
*
- * **WARNING:** ignore lazy filtering, all preference values are loaded from database
+ * **WARNING:** ignore lazy filtering, all config values are loaded from database
* unless lazy is set to false
*
* @param string $userId id of the user
* @param string $app id of the app
- * @param string $key preference key
+ * @param string $key config key
* @param bool $lazy lazy loading
*
- * @return int a bitflag in relation to the preference value
- * @throws UnknownKeyException if preference key is not known
- * @throws IncorrectTypeException if preferences value type is not known
+ * @return int a bitflag in relation to the config value
+ * @throws UnknownKeyException if config key is not known
+ * @throws IncorrectTypeException if config value type is not known
* @since 31.0.0
*/
public function getValueFlags(string $userId, string $app, string $key, bool $lazy = false): int;
/**
- * Store a preference key and its value in database
+ * Store a config key and its value in database
*
- * If preference key is already known with the exact same preference value, the database is not updated.
- * If preference key is not supposed to be read during the boot of the cloud, it is advised to set it as lazy loaded.
+ * If config key is already known with the exact same config value, the database is not updated.
+ * If config key is not supposed to be read during the boot of the cloud, it is advised to set it as lazy loaded.
*
- * If preference value was previously stored as sensitive or lazy loaded, status cannot be altered without using {@see deleteKey()} first
+ * If config value was previously stored as sensitive or lazy loaded, status cannot be altered without using {@see deleteKey()} first
*
* @param string $userId id of the user
* @param string $app id of the app
- * @param string $key preference key
- * @param string $value preference value
- * @param bool $sensitive if TRUE value will be hidden when listing preference values.
- * @param bool $lazy set preference as lazy loaded
+ * @param string $key config key
+ * @param string $value config value
+ * @param bool $sensitive if TRUE value will be hidden when listing config values.
+ * @param bool $lazy set config as lazy loaded
*
* @return bool TRUE if value was different, therefor updated in database
* @since 31.0.0
- * @see IUserPreferences for explanation about lazy loading
+ * @see IUserConfig for explanation about lazy loading
* @see setValueInt()
* @see setValueFloat()
* @see setValueBool()
@@ -426,28 +426,28 @@ interface IUserPreferences {
public function setValueString(string $userId, string $app, string $key, string $value, bool $lazy = false, int $flags = 0): bool;
/**
- * Store a preference key and its value in database
+ * Store a config key and its value in database
*
* When handling huge value around and/or above 2,147,483,647, a debug log will be generated
* on 64bits system, as php int type reach its limit (and throw an exception) on 32bits when using huge numbers.
*
* When using huge numbers, it is advised to use {@see \OCP\Util::numericToNumber()} and {@see setValueString()}
*
- * If preference key is already known with the exact same preference value, the database is not updated.
- * If preference key is not supposed to be read during the boot of the cloud, it is advised to set it as lazy loaded.
+ * If config key is already known with the exact same config value, the database is not updated.
+ * If config key is not supposed to be read during the boot of the cloud, it is advised to set it as lazy loaded.
*
- * If preference value was previously stored as sensitive or lazy loaded, status cannot be altered without using {@see deleteKey()} first
+ * If config value was previously stored as sensitive or lazy loaded, status cannot be altered without using {@see deleteKey()} first
*
* @param string $userId id of the user
* @param string $app id of the app
- * @param string $key preference key
- * @param int $value preference value
- * @param bool $sensitive if TRUE value will be hidden when listing preference values.
- * @param bool $lazy set preference as lazy loaded
+ * @param string $key config key
+ * @param int $value config value
+ * @param bool $sensitive if TRUE value will be hidden when listing config values.
+ * @param bool $lazy set config as lazy loaded
*
* @return bool TRUE if value was different, therefor updated in database
* @since 31.0.0
- * @see IUserPreferences for explanation about lazy loading
+ * @see IUserConfig for explanation about lazy loading
* @see setValueString()
* @see setValueFloat()
* @see setValueBool()
@@ -456,23 +456,23 @@ interface IUserPreferences {
public function setValueInt(string $userId, string $app, string $key, int $value, bool $lazy = false, int $flags = 0): bool;
/**
- * Store a preference key and its value in database.
+ * Store a config key and its value in database.
*
- * If preference key is already known with the exact same preference value, the database is not updated.
- * If preference key is not supposed to be read during the boot of the cloud, it is advised to set it as lazy loaded.
+ * If config key is already known with the exact same config value, the database is not updated.
+ * If config key is not supposed to be read during the boot of the cloud, it is advised to set it as lazy loaded.
*
- * If preference value was previously stored as sensitive or lazy loaded, status cannot be altered without using {@see deleteKey()} first
+ * If config value was previously stored as sensitive or lazy loaded, status cannot be altered without using {@see deleteKey()} first
*
* @param string $userId id of the user
* @param string $app id of the app
- * @param string $key preference key
- * @param float $value preference value
- * @param bool $sensitive if TRUE value will be hidden when listing preference values.
- * @param bool $lazy set preference as lazy loaded
+ * @param string $key config key
+ * @param float $value config value
+ * @param bool $sensitive if TRUE value will be hidden when listing config values.
+ * @param bool $lazy set config as lazy loaded
*
* @return bool TRUE if value was different, therefor updated in database
* @since 31.0.0
- * @see IUserPreferences for explanation about lazy loading
+ * @see IUserConfig for explanation about lazy loading
* @see setValueString()
* @see setValueInt()
* @see setValueBool()
@@ -481,22 +481,22 @@ interface IUserPreferences {
public function setValueFloat(string $userId, string $app, string $key, float $value, bool $lazy = false, int $flags = 0): bool;
/**
- * Store a preference key and its value in database
+ * Store a config key and its value in database
*
- * If preference key is already known with the exact same preference value, the database is not updated.
- * If preference key is not supposed to be read during the boot of the cloud, it is advised to set it as lazy loaded.
+ * If config key is already known with the exact same config value, the database is not updated.
+ * If config key is not supposed to be read during the boot of the cloud, it is advised to set it as lazy loaded.
*
- * If preference value was previously stored as lazy loaded, status cannot be altered without using {@see deleteKey()} first
+ * If config value was previously stored as lazy loaded, status cannot be altered without using {@see deleteKey()} first
*
* @param string $userId id of the user
* @param string $app id of the app
- * @param string $key preference key
- * @param bool $value preference value
- * @param bool $lazy set preference as lazy loaded
+ * @param string $key config key
+ * @param bool $value config value
+ * @param bool $lazy set config as lazy loaded
*
* @return bool TRUE if value was different, therefor updated in database
* @since 31.0.0
- * @see IUserPreferences for explanation about lazy loading
+ * @see IUserConfig for explanation about lazy loading
* @see setValueString()
* @see setValueInt()
* @see setValueFloat()
@@ -505,23 +505,23 @@ interface IUserPreferences {
public function setValueBool(string $userId, string $app, string $key, bool $value, bool $lazy = false): bool;
/**
- * Store a preference key and its value in database
+ * Store a config key and its value in database
*
- * If preference key is already known with the exact same preference value, the database is not updated.
- * If preference key is not supposed to be read during the boot of the cloud, it is advised to set it as lazy loaded.
+ * If config key is already known with the exact same config value, the database is not updated.
+ * If config key is not supposed to be read during the boot of the cloud, it is advised to set it as lazy loaded.
*
- * If preference value was previously stored as sensitive or lazy loaded, status cannot be altered without using {@see deleteKey()} first
+ * If config value was previously stored as sensitive or lazy loaded, status cannot be altered without using {@see deleteKey()} first
*
* @param string $userId id of the user
* @param string $app id of the app
- * @param string $key preference key
- * @param array $value preference value
- * @param bool $sensitive if TRUE value will be hidden when listing preference values.
- * @param bool $lazy set preference as lazy loaded
+ * @param string $key config key
+ * @param array $value config value
+ * @param bool $sensitive if TRUE value will be hidden when listing config values.
+ * @param bool $lazy set config as lazy loaded
*
* @return bool TRUE if value was different, therefor updated in database
* @since 31.0.0
- * @see IUserPreferences for explanation about lazy loading
+ * @see IUserConfig for explanation about lazy loading
* @see setValueString()
* @see setValueInt()
* @see setValueFloat()
@@ -530,13 +530,13 @@ interface IUserPreferences {
public function setValueArray(string $userId, string $app, string $key, array $value, bool $lazy = false, int $flags = 0): bool;
/**
- * switch sensitive status of a preference value
+ * switch sensitive status of a config value
*
- * **WARNING:** ignore lazy filtering, all preference values are loaded from database
+ * **WARNING:** ignore lazy filtering, all config values are loaded from database
*
* @param string $userId id of the user
* @param string $app id of the app
- * @param string $key preference key
+ * @param string $key config key
* @param bool $sensitive TRUE to set as sensitive, FALSE to unset
*
* @return bool TRUE if database update were necessary
@@ -545,12 +545,12 @@ interface IUserPreferences {
public function updateSensitive(string $userId, string $app, string $key, bool $sensitive): bool;
/**
- * switch sensitive loading status of a preference key for all users
+ * switch sensitive loading status of a config key for all users
*
* **Warning:** heavy on resources, MUST only be used on occ command or migrations
*
* @param string $app id of the app
- * @param string $key preference key
+ * @param string $key config key
* @param bool $sensitive TRUE to set as sensitive, FALSE to unset
*
* @since 31.0.0
@@ -559,13 +559,13 @@ interface IUserPreferences {
/**
- * switch indexed status of a preference value
+ * switch indexed status of a config value
*
- * **WARNING:** ignore lazy filtering, all preference values are loaded from database
+ * **WARNING:** ignore lazy filtering, all config values are loaded from database
*
* @param string $userId id of the user
* @param string $app id of the app
- * @param string $key preference key
+ * @param string $key config key
* @param bool $indexed TRUE to set as indexed, FALSE to unset
*
* @return bool TRUE if database update were necessary
@@ -574,23 +574,23 @@ interface IUserPreferences {
public function updateIndexed(string $userId, string $app, string $key, bool $indexed): bool;
/**
- * switch sensitive loading status of a preference key for all users
+ * switch sensitive loading status of a config key for all users
*
* **Warning:** heavy on resources, MUST only be used on occ command or migrations
*
* @param string $app id of the app
- * @param string $key preference key
+ * @param string $key config key
* @param bool $indexed TRUE to set as indexed, FALSE to unset
* @since 31.0.0
*/
public function updateGlobalIndexed(string $app, string $key, bool $indexed): void;
/**
- * switch lazy loading status of a preference value
+ * switch lazy loading status of a config value
*
* @param string $userId id of the user
* @param string $app id of the app
- * @param string $key preference key
+ * @param string $key config key
* @param bool $lazy TRUE to set as lazy loaded, FALSE to unset
*
* @return bool TRUE if database update was necessary
@@ -599,19 +599,19 @@ interface IUserPreferences {
public function updateLazy(string $userId, string $app, string $key, bool $lazy): bool;
/**
- * switch lazy loading status of a preference key for all users
+ * switch lazy loading status of a config key for all users
*
* **Warning:** heavy on resources, MUST only be used on occ command or migrations
*
* @param string $app id of the app
- * @param string $key preference key
+ * @param string $key config key
* @param bool $lazy TRUE to set as lazy loaded, FALSE to unset
* @since 31.0.0
*/
public function updateGlobalLazy(string $app, string $key, bool $lazy): void;
/**
- * returns an array contains details about a preference value
+ * returns an array contains details about a config value
*
* ```
* [
@@ -627,37 +627,37 @@ interface IUserPreferences {
*
* @param string $userId id of the user
* @param string $app id of the app
- * @param string $key preference key
+ * @param string $key config key
*
* @return array
- * @throws UnknownKeyException if preference key is not known in database
+ * @throws UnknownKeyException if config key is not known in database
* @since 31.0.0
*/
public function getDetails(string $userId, string $app, string $key): array;
/**
- * Delete single preference key from database.
+ * Delete single config key from database.
*
* @param string $userId id of the user
* @param string $app id of the app
- * @param string $key preference key
+ * @param string $key config key
*
* @since 31.0.0
*/
- public function deletePreference(string $userId, string $app, string $key): void;
+ public function deleteUserConfig(string $userId, string $app, string $key): void;
/**
- * Delete preference values from all users linked to a specific preference keys
+ * Delete config values from all users linked to a specific config keys
*
* @param string $app id of the app
- * @param string $key preference key
+ * @param string $key config key
*
* @since 31.0.0
*/
public function deleteKey(string $app, string $key): void;
/**
- * delete all preference keys linked to an app
+ * delete all config keys linked to an app
*
* @param string $app id of the app
* @since 31.0.0
@@ -665,17 +665,17 @@ interface IUserPreferences {
public function deleteApp(string $app): void;
/**
- * delete all preference keys linked to a user
+ * delete all config keys linked to a user
*
* @param string $userId id of the user
* @since 31.0.0
*/
- public function deleteAllPreferences(string $userId): void;
+ public function deleteAllUserConfig(string $userId): void;
/**
* Clear the cache for a single user
*
- * The cache will be rebuilt only the next time a user preference is requested.
+ * The cache will be rebuilt only the next time a user config is requested.
*
* @param string $userId id of the user
* @param bool $reload set to TRUE to refill cache instantly after clearing it
@@ -686,7 +686,7 @@ interface IUserPreferences {
/**
* Clear the cache for all users.
- * The cache will be rebuilt only the next time a user preference is requested.
+ * The cache will be rebuilt only the next time a user config is requested.
*
* @since 31.0.0
*/
diff --git a/lib/unstable/Config/ValueType.php b/lib/unstable/Config/ValueType.php
index 2c3c5851e3f..3e1e47e9d7c 100644
--- a/lib/unstable/Config/ValueType.php
+++ b/lib/unstable/Config/ValueType.php
@@ -14,6 +14,7 @@ use UnhandledMatchError;
/**
* Listing of available value type for typed config value
*
+ * @experimental 31.0.0
* @since 31.0.0
*/
enum ValueType: int {
diff --git a/tests/lib/UserPreferencesTest.php b/tests/lib/Config/UserConfigTest.php
index c149af002d3..a79e1e59a79 100644
--- a/tests/lib/UserPreferencesTest.php
+++ b/tests/lib/Config/UserConfigTest.php
@@ -5,13 +5,13 @@ declare(strict_types=1);
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-only
*/
-namespace lib;
+namespace lib\Config;
use NCU\Config\Exceptions\TypeConflictException;
use NCU\Config\Exceptions\UnknownKeyException;
-use NCU\Config\IUserPreferences;
+use NCU\Config\IUserConfig;
use NCU\Config\ValueType;
-use OC\Config\UserPreferences;
+use OC\Config\UserConfig;
use OCP\IDBConnection;
use OCP\Security\ICrypto;
use Psr\Log\LoggerInterface;
@@ -24,7 +24,7 @@ use Test\TestCase;
*
* @package Test
*/
-class UserPreferencesTest extends TestCase {
+class UserConfigTest extends TestCase {
protected IDBConnection $connection;
private LoggerInterface $logger;
private ICrypto $crypto;
@@ -43,30 +43,30 @@ class UserPreferencesTest extends TestCase {
'fast_string' => ['fast_string', 'f_value', ValueType::STRING],
'lazy_string' => ['lazy_string', 'l_value', ValueType::STRING, true],
'fast_string_sensitive' => [
- 'fast_string_sensitive', 'fs_value', ValueType::STRING, false, UserPreferences::FLAG_SENSITIVE
+ 'fast_string_sensitive', 'fs_value', ValueType::STRING, false, UserConfig::FLAG_SENSITIVE
],
'lazy_string_sensitive' => [
- 'lazy_string_sensitive', 'ls_value', ValueType::STRING, true, UserPreferences::FLAG_SENSITIVE
+ 'lazy_string_sensitive', 'ls_value', ValueType::STRING, true, UserConfig::FLAG_SENSITIVE
],
'fast_int' => ['fast_int', 11, ValueType::INT],
'lazy_int' => ['lazy_int', 12, ValueType::INT, true],
- 'fast_int_sensitive' => ['fast_int_sensitive', 2024, ValueType::INT, false, UserPreferences::FLAG_SENSITIVE],
- 'lazy_int_sensitive' => ['lazy_int_sensitive', 2048, ValueType::INT, true, UserPreferences::FLAG_SENSITIVE],
+ 'fast_int_sensitive' => ['fast_int_sensitive', 2024, ValueType::INT, false, UserConfig::FLAG_SENSITIVE],
+ 'lazy_int_sensitive' => ['lazy_int_sensitive', 2048, ValueType::INT, true, UserConfig::FLAG_SENSITIVE],
'fast_float' => ['fast_float', 3.14, ValueType::FLOAT],
'lazy_float' => ['lazy_float', 3.14159, ValueType::FLOAT, true],
'fast_float_sensitive' => [
- 'fast_float_sensitive', 1.41, ValueType::FLOAT, false, UserPreferences::FLAG_SENSITIVE
+ 'fast_float_sensitive', 1.41, ValueType::FLOAT, false, UserConfig::FLAG_SENSITIVE
],
'lazy_float_sensitive' => [
- 'lazy_float_sensitive', 1.4142, ValueType::FLOAT, true, UserPreferences::FLAG_SENSITIVE
+ 'lazy_float_sensitive', 1.4142, ValueType::FLOAT, true, UserConfig::FLAG_SENSITIVE
],
'fast_array' => ['fast_array', ['year' => 2024], ValueType::ARRAY],
'lazy_array' => ['lazy_array', ['month' => 'October'], ValueType::ARRAY, true],
'fast_array_sensitive' => [
- 'fast_array_sensitive', ['password' => 'pwd'], ValueType::ARRAY, false, UserPreferences::FLAG_SENSITIVE
+ 'fast_array_sensitive', ['password' => 'pwd'], ValueType::ARRAY, false, UserConfig::FLAG_SENSITIVE
],
'lazy_array_sensitive' => [
- 'lazy_array_sensitive', ['password' => 'qwerty'], ValueType::ARRAY, true, UserPreferences::FLAG_SENSITIVE
+ 'lazy_array_sensitive', ['password' => 'qwerty'], ValueType::ARRAY, true, UserConfig::FLAG_SENSITIVE
],
'fast_boolean' => ['fast_boolean', true, ValueType::BOOL],
'fast_boolean_0' => ['fast_boolean_0', false, ValueType::BOOL],
@@ -76,20 +76,20 @@ class UserPreferencesTest extends TestCase {
'app2' => [
'key2' => ['key2', 'value2a', ValueType::STRING, false, 0, true],
'key3' => ['key3', 'value3', ValueType::STRING, true],
- 'key4' => ['key4', 'value4', ValueType::STRING, false, UserPreferences::FLAG_SENSITIVE],
+ 'key4' => ['key4', 'value4', ValueType::STRING, false, UserConfig::FLAG_SENSITIVE],
'key8' => ['key8', 11, ValueType::INT, false, 0, true],
'key9' => ['key9', 'value9a', ValueType::STRING],
],
'app3' => [
'key1' => ['key1', 'value123'],
'key3' => ['key3', 'value3'],
- 'key8' => ['key8', 12, ValueType::INT, false, UserPreferences::FLAG_SENSITIVE, true],
- 'key9' => ['key9', 'value9b', ValueType::STRING, false, UserPreferences::FLAG_SENSITIVE],
+ 'key8' => ['key8', 12, ValueType::INT, false, UserConfig::FLAG_SENSITIVE, true],
+ 'key9' => ['key9', 'value9b', ValueType::STRING, false, UserConfig::FLAG_SENSITIVE],
'key10' => ['key10', true, ValueType::BOOL, false, 0, true],
],
'only-lazy' => [
'key1' => ['key1', 'value456', ValueType::STRING, true, 0, true],
- 'key2' => ['key2', 'value2c', ValueType::STRING, true, UserPreferences::FLAG_SENSITIVE],
+ 'key2' => ['key2', 'value2c', ValueType::STRING, true, UserConfig::FLAG_SENSITIVE],
'key3' => ['key3', 42, ValueType::INT, true],
'key4' => ['key4', 17.42, ValueType::FLOAT, true],
'key5' => ['key5', true, ValueType::BOOL, true],
@@ -99,16 +99,16 @@ class UserPreferencesTest extends TestCase {
[
'app1' => [
'1' => ['1', 'value1'],
- '2' => ['2', 'value2', ValueType::STRING, true, UserPreferences::FLAG_SENSITIVE],
+ '2' => ['2', 'value2', ValueType::STRING, true, UserConfig::FLAG_SENSITIVE],
'3' => ['3', 17, ValueType::INT, true],
- '4' => ['4', 42, ValueType::INT, false, UserPreferences::FLAG_SENSITIVE],
+ '4' => ['4', 42, ValueType::INT, false, UserConfig::FLAG_SENSITIVE],
'5' => ['5', 17.42, ValueType::FLOAT, false],
'6' => ['6', true, ValueType::BOOL, false],
],
'app2' => [
'key2' => ['key2', 'value2b', ValueType::STRING, false, 0, true],
'key3' => ['key3', 'value3', ValueType::STRING, true],
- 'key4' => ['key4', 'value4', ValueType::STRING, false, UserPreferences::FLAG_SENSITIVE],
+ 'key4' => ['key4', 'value4', ValueType::STRING, false, UserConfig::FLAG_SENSITIVE],
'key8' => ['key8', 12, ValueType::INT, false, 0, true],
],
'app3' => [
@@ -123,12 +123,12 @@ class UserPreferencesTest extends TestCase {
'app2' => [
'key2' => ['key2', 'value2c', ValueType::MIXED, false, 0, true],
'key3' => ['key3', 'value3', ValueType::STRING, true, ],
- 'key4' => ['key4', 'value4', ValueType::STRING, false, UserPreferences::FLAG_SENSITIVE],
+ 'key4' => ['key4', 'value4', ValueType::STRING, false, UserConfig::FLAG_SENSITIVE],
'fast_string_sensitive' => [
- 'fast_string_sensitive', 'fs_value', ValueType::STRING, false, UserPreferences::FLAG_SENSITIVE
+ 'fast_string_sensitive', 'fs_value', ValueType::STRING, false, UserConfig::FLAG_SENSITIVE
],
'lazy_string_sensitive' => [
- 'lazy_string_sensitive', 'ls_value', ValueType::STRING, true, UserPreferences::FLAG_SENSITIVE
+ 'lazy_string_sensitive', 'ls_value', ValueType::STRING, true, UserConfig::FLAG_SENSITIVE
],
],
'only-lazy' => [
@@ -141,7 +141,7 @@ class UserPreferencesTest extends TestCase {
'key1' => ['key1', 'value1'],
'key2' => ['key2', 'value2A', ValueType::MIXED, false, 0, true],
'key3' => ['key3', 'value3', ValueType::STRING, true,],
- 'key4' => ['key4', 'value4', ValueType::STRING, false, UserPreferences::FLAG_SENSITIVE],
+ 'key4' => ['key4', 'value4', ValueType::STRING, false, UserConfig::FLAG_SENSITIVE],
],
'app3' => [
'key10' => ['key10', true, ValueType::BOOL, false, 0, true],
@@ -214,8 +214,8 @@ class UserPreferencesTest extends TestCase {
}
$flags = $row[4] ?? 0;
- if ((UserPreferences::FLAG_SENSITIVE & $flags) !== 0) {
- $value = self::invokePrivate(UserPreferences::class, 'ENCRYPTION_PREFIX')
+ if ((UserConfig::FLAG_SENSITIVE & $flags) !== 0) {
+ $value = self::invokePrivate(UserConfig::class, 'ENCRYPTION_PREFIX')
. $this->crypto->encrypt((string)$value);
} else {
$indexed = (($row[5] ?? false) === true) ? $value : '';
@@ -272,28 +272,28 @@ class UserPreferencesTest extends TestCase {
/**
* @param array $preLoading preload the 'fast' cache for a list of users)
*
- * @return IUserPreferences
+ * @return IUserConfig
*/
- private function generateUserPreferences(array $preLoading = []): IUserPreferences {
- $preferences = new \OC\Config\UserPreferences(
+ private function generateUserConfig(array $preLoading = []): IUserConfig {
+ $userConfig = new \OC\Config\UserConfig(
$this->connection,
$this->logger,
$this->crypto,
);
- $msg = ' generateUserPreferences() failed to confirm cache status';
+ $msg = ' generateUserConfig() failed to confirm cache status';
// confirm cache status
- $status = $preferences->statusCache();
+ $status = $userConfig->statusCache();
$this->assertSame([], $status['fastLoaded'], $msg);
$this->assertSame([], $status['lazyLoaded'], $msg);
$this->assertSame([], $status['fastCache'], $msg);
$this->assertSame([], $status['lazyCache'], $msg);
foreach ($preLoading as $preLoadUser) {
// simple way to initiate the load of non-lazy preferences values in cache
- $preferences->getValueString($preLoadUser, 'core', 'preload');
+ $userConfig->getValueString($preLoadUser, 'core', 'preload');
// confirm cache status
- $status = $preferences->statusCache();
+ $status = $userConfig->statusCache();
$this->assertSame(true, $status['fastLoaded'][$preLoadUser], $msg);
$this->assertSame(false, $status['lazyLoaded'][$preLoadUser], $msg);
@@ -302,30 +302,30 @@ class UserPreferencesTest extends TestCase {
$this->assertSame([], array_keys($status['lazyCache'][$preLoadUser]), $msg);
}
- return $preferences;
+ return $userConfig;
}
public function testGetUserIdsEmpty(): void {
- $preferences = $this->generateUserPreferences();
- $this->assertEqualsCanonicalizing(array_keys($this->basePreferences), $preferences->getUserIds());
+ $userConfig = $this->generateUserConfig();
+ $this->assertEqualsCanonicalizing(array_keys($this->basePreferences), $userConfig->getUserIds());
}
public function testGetUserIds(): void {
- $preferences = $this->generateUserPreferences();
- $this->assertEqualsCanonicalizing(['user1', 'user2', 'user5'], $preferences->getUserIds('app1'));
+ $userConfig = $this->generateUserConfig();
+ $this->assertEqualsCanonicalizing(['user1', 'user2', 'user5'], $userConfig->getUserIds('app1'));
}
public function testGetApps(): void {
- $preferences = $this->generateUserPreferences();
+ $userConfig = $this->generateUserConfig();
$this->assertEqualsCanonicalizing(
- array_keys($this->basePreferences['user1']), $preferences->getApps('user1')
+ array_keys($this->basePreferences['user1']), $userConfig->getApps('user1')
);
}
public function testGetKeys(): void {
- $preferences = $this->generateUserPreferences(['user1']);
+ $userConfig = $this->generateUserConfig(['user1']);
$this->assertEqualsCanonicalizing(
- array_keys($this->basePreferences['user1']['app1']), $preferences->getKeys('user1', 'app1')
+ array_keys($this->basePreferences['user1']['app1']), $userConfig->getKeys('user1', 'app1')
);
}
@@ -350,8 +350,8 @@ class UserPreferencesTest extends TestCase {
* @dataProvider providerHasKey
*/
public function testHasKey(string $userId, string $appId, string $key, ?bool $lazy, bool $result): void {
- $preferences = $this->generateUserPreferences();
- $this->assertEquals($result, $preferences->hasKey($userId, $appId, $key, $lazy));
+ $userConfig = $this->generateUserConfig();
+ $this->assertEquals($result, $userConfig->hasKey($userId, $appId, $key, $lazy));
}
/**
@@ -387,12 +387,12 @@ class UserPreferencesTest extends TestCase {
bool $result,
bool $exception,
): void {
- $preferences = $this->generateUserPreferences();
+ $userConfig = $this->generateUserConfig();
if ($exception) {
$this->expectException(UnknownKeyException::class);
}
- $this->assertEquals($result, $preferences->isSensitive($userId, $appId, $key, $lazy));
+ $this->assertEquals($result, $userConfig->isSensitive($userId, $appId, $key, $lazy));
}
/**
@@ -420,12 +420,12 @@ class UserPreferencesTest extends TestCase {
bool $result,
bool $exception,
): void {
- $preferences = $this->generateUserPreferences();
+ $userConfig = $this->generateUserConfig();
if ($exception) {
$this->expectException(UnknownKeyException::class);
}
- $this->assertEquals($result, $preferences->isLazy($userId, $appId, $key));
+ $this->assertEquals($result, $userConfig->isLazy($userId, $appId, $key));
}
public function providerGetValues(): array {
@@ -555,9 +555,9 @@ class UserPreferencesTest extends TestCase {
bool $filtered,
array $result,
): void {
- $preferences = $this->generateUserPreferences();
+ $userConfig = $this->generateUserConfig();
$this->assertJsonStringEqualsJsonString(
- json_encode($result), json_encode($preferences->getValues($userId, $appId, $prefix, $filtered))
+ json_encode($result), json_encode($userConfig->getValues($userId, $appId, $prefix, $filtered))
);
}
@@ -654,8 +654,8 @@ class UserPreferencesTest extends TestCase {
bool $filtered,
array $result,
): void {
- $preferences = $this->generateUserPreferences();
- $this->assertEqualsCanonicalizing($result, $preferences->getAllValues($userId, $filtered));
+ $userConfig = $this->generateUserConfig();
+ $this->assertEqualsCanonicalizing($result, $userConfig->getAllValues($userId, $filtered));
}
public function providerSearchValuesByApps(): array {
@@ -700,8 +700,8 @@ class UserPreferencesTest extends TestCase {
?ValueType $typedAs,
array $result,
): void {
- $preferences = $this->generateUserPreferences();
- $this->assertEquals($result, $preferences->getValuesByApps($userId, $key, $lazy, $typedAs));
+ $userConfig = $this->generateUserConfig();
+ $this->assertEquals($result, $userConfig->getValuesByApps($userId, $key, $lazy, $typedAs));
}
public function providerSearchValuesByUsers(): array {
@@ -750,9 +750,9 @@ class UserPreferencesTest extends TestCase {
?array $userIds = null,
array $result,
): void {
- $preferences = $this->generateUserPreferences();
+ $userConfig = $this->generateUserConfig();
$this->assertEqualsCanonicalizing(
- $result, $preferences->getValuesByUsers($app, $key, $typedAs, $userIds)
+ $result, $userConfig->getValuesByUsers($app, $key, $typedAs, $userIds)
);
}
@@ -774,8 +774,8 @@ class UserPreferencesTest extends TestCase {
bool $ci,
array $result,
): void {
- $preferences = $this->generateUserPreferences();
- $this->assertEqualsCanonicalizing($result, iterator_to_array($preferences->searchUsersByValueString($app, $key, $value, $ci)));
+ $userConfig = $this->generateUserConfig();
+ $this->assertEqualsCanonicalizing($result, iterator_to_array($userConfig->searchUsersByValueString($app, $key, $value, $ci)));
}
public function providerSearchValuesByValueInt(): array {
@@ -795,8 +795,8 @@ class UserPreferencesTest extends TestCase {
int $value,
array $result,
): void {
- $preferences = $this->generateUserPreferences();
- $this->assertEqualsCanonicalizing($result, iterator_to_array($preferences->searchUsersByValueInt($app, $key, $value)));
+ $userConfig = $this->generateUserConfig();
+ $this->assertEqualsCanonicalizing($result, iterator_to_array($userConfig->searchUsersByValueInt($app, $key, $value)));
}
public function providerSearchValuesByValues(): array {
@@ -815,8 +815,8 @@ class UserPreferencesTest extends TestCase {
array $values,
array $result,
): void {
- $preferences = $this->generateUserPreferences();
- $this->assertEqualsCanonicalizing($result, iterator_to_array($preferences->searchUsersByValues($app, $key, $values)));
+ $userConfig = $this->generateUserConfig();
+ $this->assertEqualsCanonicalizing($result, iterator_to_array($userConfig->searchUsersByValues($app, $key, $values)));
}
public function providerSearchValuesByValueBool(): array {
@@ -835,8 +835,8 @@ class UserPreferencesTest extends TestCase {
bool $value,
array $result,
): void {
- $preferences = $this->generateUserPreferences();
- $this->assertEqualsCanonicalizing($result, iterator_to_array($preferences->searchUsersByValueBool($app, $key, $value)));
+ $userConfig = $this->generateUserConfig();
+ $this->assertEqualsCanonicalizing($result, iterator_to_array($userConfig->searchUsersByValueBool($app, $key, $value)));
}
public function providerGetValueMixed(): array {
@@ -919,8 +919,8 @@ class UserPreferencesTest extends TestCase {
bool $lazy,
string $result,
): void {
- $preferences = $this->generateUserPreferences($preload ?? []);
- $this->assertEquals($result, $preferences->getValueMixed($userId, $app, $key, $default, $lazy));
+ $userConfig = $this->generateUserConfig($preload ?? []);
+ $this->assertEquals($result, $userConfig->getValueMixed($userId, $app, $key, $default, $lazy));
}
/**
@@ -935,8 +935,8 @@ class UserPreferencesTest extends TestCase {
bool $lazy,
string $result,
): void {
- $preferences = $this->generateUserPreferences($preload ?? []);
- $this->assertEquals($result, $preferences->getValueString($userId, $app, $key, $default, $lazy));
+ $userConfig = $this->generateUserConfig($preload ?? []);
+ $this->assertEquals($result, $userConfig->getValueString($userId, $app, $key, $default, $lazy));
}
public function providerGetValueInt(): array {
@@ -977,8 +977,8 @@ class UserPreferencesTest extends TestCase {
bool $lazy,
int $result,
): void {
- $preferences = $this->generateUserPreferences($preload ?? []);
- $this->assertEquals($result, $preferences->getValueInt($userId, $app, $key, $default, $lazy));
+ $userConfig = $this->generateUserConfig($preload ?? []);
+ $this->assertEquals($result, $userConfig->getValueInt($userId, $app, $key, $default, $lazy));
}
public function providerGetValueFloat(): array {
@@ -1018,8 +1018,8 @@ class UserPreferencesTest extends TestCase {
bool $lazy,
float $result,
): void {
- $preferences = $this->generateUserPreferences($preload ?? []);
- $this->assertEquals($result, $preferences->getValueFloat($userId, $app, $key, $default, $lazy));
+ $userConfig = $this->generateUserConfig($preload ?? []);
+ $this->assertEquals($result, $userConfig->getValueFloat($userId, $app, $key, $default, $lazy));
}
public function providerGetValueBool(): array {
@@ -1079,8 +1079,8 @@ class UserPreferencesTest extends TestCase {
bool $lazy,
bool $result,
): void {
- $preferences = $this->generateUserPreferences($preload ?? []);
- $this->assertEquals($result, $preferences->getValueBool($userId, $app, $key, $default, $lazy));
+ $userConfig = $this->generateUserConfig($preload ?? []);
+ $this->assertEquals($result, $userConfig->getValueBool($userId, $app, $key, $default, $lazy));
}
public function providerGetValueArray(): array {
@@ -1116,9 +1116,9 @@ class UserPreferencesTest extends TestCase {
bool $lazy,
array $result,
): void {
- $preferences = $this->generateUserPreferences($preload ?? []);
+ $userConfig = $this->generateUserConfig($preload ?? []);
$this->assertEqualsCanonicalizing(
- $result, $preferences->getValueArray($userId, $app, $key, $default, $lazy)
+ $result, $userConfig->getValueArray($userId, $app, $key, $default, $lazy)
);
}
@@ -1172,12 +1172,12 @@ class UserPreferencesTest extends TestCase {
?ValueType $result,
?string $exception = null,
): void {
- $preferences = $this->generateUserPreferences($preload ?? []);
+ $userConfig = $this->generateUserConfig($preload ?? []);
if ($exception !== null) {
$this->expectException($exception);
}
- $type = $preferences->getValueType($userId, $app, $key, $lazy);
+ $type = $userConfig->getValueType($userId, $app, $key, $lazy);
if ($exception === null) {
$this->assertEquals($result->value, $type->value);
}
@@ -1233,12 +1233,12 @@ class UserPreferencesTest extends TestCase {
bool $result,
?string $exception = null,
): void {
- $preferences = $this->generateUserPreferences($preload ?? []);
+ $userConfig = $this->generateUserConfig($preload ?? []);
if ($exception !== null) {
$this->expectException($exception);
}
- $edited = $preferences->setValueMixed($userId, $app, $key, $value, $lazy, ($sensitive) ? 1 : 0);
+ $edited = $userConfig->setValueMixed($userId, $app, $key, $value, $lazy, ($sensitive) ? 1 : 0);
if ($exception === null) {
$this->assertEquals($result, $edited);
@@ -1303,21 +1303,21 @@ class UserPreferencesTest extends TestCase {
bool $result,
?string $exception = null,
): void {
- $preferences = $this->generateUserPreferences($preload ?? []);
+ $userConfig = $this->generateUserConfig($preload ?? []);
if ($exception !== null) {
$this->expectException($exception);
}
- $edited = $preferences->setValueString($userId, $app, $key, $value, $lazy, ($sensitive) ? 1 : 0);
+ $edited = $userConfig->setValueString($userId, $app, $key, $value, $lazy, ($sensitive) ? 1 : 0);
if ($exception !== null) {
return;
}
$this->assertEquals($result, $edited);
if ($result) {
- $this->assertEquals($value, $preferences->getValueString($userId, $app, $key, $value, $lazy));
- $preferences = $this->generateUserPreferences($preload ?? []);
- $this->assertEquals($value, $preferences->getValueString($userId, $app, $key, $value, $lazy));
+ $this->assertEquals($value, $userConfig->getValueString($userId, $app, $key, $value, $lazy));
+ $userConfig = $this->generateUserConfig($preload ?? []);
+ $this->assertEquals($value, $userConfig->getValueString($userId, $app, $key, $value, $lazy));
}
}
@@ -1366,12 +1366,12 @@ class UserPreferencesTest extends TestCase {
bool $result,
?string $exception = null,
): void {
- $preferences = $this->generateUserPreferences($preload ?? []);
+ $userConfig = $this->generateUserConfig($preload ?? []);
if ($exception !== null) {
$this->expectException($exception);
}
- $edited = $preferences->setValueInt($userId, $app, $key, $value, $lazy, ($sensitive) ? 1 : 0);
+ $edited = $userConfig->setValueInt($userId, $app, $key, $value, $lazy, ($sensitive) ? 1 : 0);
if ($exception !== null) {
return;
@@ -1379,9 +1379,9 @@ class UserPreferencesTest extends TestCase {
$this->assertEquals($result, $edited);
if ($result) {
- $this->assertEquals($value, $preferences->getValueInt($userId, $app, $key, $value, $lazy));
- $preferences = $this->generateUserPreferences($preload ?? []);
- $this->assertEquals($value, $preferences->getValueInt($userId, $app, $key, $value, $lazy));
+ $this->assertEquals($value, $userConfig->getValueInt($userId, $app, $key, $value, $lazy));
+ $userConfig = $this->generateUserConfig($preload ?? []);
+ $this->assertEquals($value, $userConfig->getValueInt($userId, $app, $key, $value, $lazy));
}
}
@@ -1429,12 +1429,12 @@ class UserPreferencesTest extends TestCase {
bool $result,
?string $exception = null,
): void {
- $preferences = $this->generateUserPreferences($preload ?? []);
+ $userConfig = $this->generateUserConfig($preload ?? []);
if ($exception !== null) {
$this->expectException($exception);
}
- $edited = $preferences->setValueFloat($userId, $app, $key, $value, $lazy, ($sensitive) ? 1 : 0);
+ $edited = $userConfig->setValueFloat($userId, $app, $key, $value, $lazy, ($sensitive) ? 1 : 0);
if ($exception !== null) {
return;
@@ -1442,9 +1442,9 @@ class UserPreferencesTest extends TestCase {
$this->assertEquals($result, $edited);
if ($result) {
- $this->assertEquals($value, $preferences->getValueFloat($userId, $app, $key, $value, $lazy));
- $preferences = $this->generateUserPreferences($preload ?? []);
- $this->assertEquals($value, $preferences->getValueFloat($userId, $app, $key, $value, $lazy));
+ $this->assertEquals($value, $userConfig->getValueFloat($userId, $app, $key, $value, $lazy));
+ $userConfig = $this->generateUserConfig($preload ?? []);
+ $this->assertEquals($value, $userConfig->getValueFloat($userId, $app, $key, $value, $lazy));
}
}
@@ -1493,12 +1493,12 @@ class UserPreferencesTest extends TestCase {
bool $result,
?string $exception = null,
): void {
- $preferences = $this->generateUserPreferences($preload ?? []);
+ $userConfig = $this->generateUserConfig($preload ?? []);
if ($exception !== null) {
$this->expectException($exception);
}
- $edited = $preferences->setValueArray($userId, $app, $key, $value, $lazy, ($sensitive) ? 1 : 0);
+ $edited = $userConfig->setValueArray($userId, $app, $key, $value, $lazy, ($sensitive) ? 1 : 0);
if ($exception !== null) {
return;
@@ -1507,11 +1507,11 @@ class UserPreferencesTest extends TestCase {
$this->assertEquals($result, $edited);
if ($result) {
$this->assertEqualsCanonicalizing(
- $value, $preferences->getValueArray($userId, $app, $key, $value, $lazy)
+ $value, $userConfig->getValueArray($userId, $app, $key, $value, $lazy)
);
- $preferences = $this->generateUserPreferences($preload ?? []);
+ $userConfig = $this->generateUserConfig($preload ?? []);
$this->assertEqualsCanonicalizing(
- $value, $preferences->getValueArray($userId, $app, $key, $value, $lazy)
+ $value, $userConfig->getValueArray($userId, $app, $key, $value, $lazy)
);
}
}
@@ -1537,26 +1537,26 @@ class UserPreferencesTest extends TestCase {
bool $result,
?string $exception = null,
): void {
- $preferences = $this->generateUserPreferences($preload ?? []);
+ $userConfig = $this->generateUserConfig($preload ?? []);
if ($exception !== null) {
$this->expectException($exception);
}
- $edited = $preferences->updateSensitive($userId, $app, $key, $sensitive);
+ $edited = $userConfig->updateSensitive($userId, $app, $key, $sensitive);
if ($exception !== null) {
return;
}
$this->assertEquals($result, $edited);
if ($result) {
- $this->assertEquals($sensitive, $preferences->isSensitive($userId, $app, $key));
- $preferences = $this->generateUserPreferences($preload ?? []);
- $this->assertEquals($sensitive, $preferences->isSensitive($userId, $app, $key));
+ $this->assertEquals($sensitive, $userConfig->isSensitive($userId, $app, $key));
+ $userConfig = $this->generateUserConfig($preload ?? []);
+ $this->assertEquals($sensitive, $userConfig->isSensitive($userId, $app, $key));
if ($sensitive) {
$this->assertEquals(true, str_starts_with(
- $preferences->statusCache()['fastCache'][$userId][$app][$key] ??
- $preferences->statusCache()['lazyCache'][$userId][$app][$key],
- '$UserPreferencesEncryption$')
+ $userConfig->statusCache()['fastCache'][$userId][$app][$key] ??
+ $userConfig->statusCache()['lazyCache'][$userId][$app][$key],
+ '$UserConfigEncryption$')
);
}
}
@@ -1570,7 +1570,7 @@ class UserPreferencesTest extends TestCase {
* @dataProvider providerUpdateGlobalSensitive
*/
public function testUpdateGlobalSensitive(bool $sensitive): void {
- $preferences = $this->generateUserPreferences($preload ?? []);
+ $userConfig = $this->generateUserConfig($preload ?? []);
$app = 'app2';
if ($sensitive) {
$key = 'key2';
@@ -1580,28 +1580,28 @@ class UserPreferencesTest extends TestCase {
$value = 'value4';
}
- $this->assertEquals($value, $preferences->getValueString('user1', $app, $key));
+ $this->assertEquals($value, $userConfig->getValueString('user1', $app, $key));
foreach (['user1', 'user2', 'user3', 'user4'] as $userId) {
- $preferences->getValueString($userId, $app, $key); // cache loading for userId
+ $userConfig->getValueString($userId, $app, $key); // cache loading for userId
$this->assertEquals(
!$sensitive, str_starts_with(
- $preferences->statusCache()['fastCache'][$userId][$app][$key] ??
- $preferences->statusCache()['lazyCache'][$userId][$app][$key],
- '$UserPreferencesEncryption$'
+ $userConfig->statusCache()['fastCache'][$userId][$app][$key] ??
+ $userConfig->statusCache()['lazyCache'][$userId][$app][$key],
+ '$UserConfigEncryption$'
)
);
}
- $preferences->updateGlobalSensitive($app, $key, $sensitive);
+ $userConfig->updateGlobalSensitive($app, $key, $sensitive);
- $this->assertEquals($value, $preferences->getValueString('user1', $app, $key));
+ $this->assertEquals($value, $userConfig->getValueString('user1', $app, $key));
foreach (['user1', 'user2', 'user3', 'user4'] as $userId) {
- $this->assertEquals($sensitive, $preferences->isSensitive($userId, $app, $key));
+ $this->assertEquals($sensitive, $userConfig->isSensitive($userId, $app, $key));
// should only work if updateGlobalSensitive drop cache
$this->assertEquals($sensitive, str_starts_with(
- $preferences->statusCache()['fastCache'][$userId][$app][$key] ??
- $preferences->statusCache()['lazyCache'][$userId][$app][$key],
- '$UserPreferencesEncryption$')
+ $userConfig->statusCache()['fastCache'][$userId][$app][$key] ??
+ $userConfig->statusCache()['lazyCache'][$userId][$app][$key],
+ '$UserConfigEncryption$')
);
}
}
@@ -1627,21 +1627,21 @@ class UserPreferencesTest extends TestCase {
bool $result,
?string $exception = null,
): void {
- $preferences = $this->generateUserPreferences($preload ?? []);
+ $userConfig = $this->generateUserConfig($preload ?? []);
if ($exception !== null) {
$this->expectException($exception);
}
- $edited = $preferences->updateLazy($userId, $app, $key, $lazy);
+ $edited = $userConfig->updateLazy($userId, $app, $key, $lazy);
if ($exception !== null) {
return;
}
$this->assertEquals($result, $edited);
if ($result) {
- $this->assertEquals($lazy, $preferences->isLazy($userId, $app, $key));
- $preferences = $this->generateUserPreferences($preload ?? []);
- $this->assertEquals($lazy, $preferences->isLazy($userId, $app, $key));
+ $this->assertEquals($lazy, $userConfig->isLazy($userId, $app, $key));
+ $userConfig = $this->generateUserConfig($preload ?? []);
+ $this->assertEquals($lazy, $userConfig->isLazy($userId, $app, $key));
}
}
@@ -1653,7 +1653,7 @@ class UserPreferencesTest extends TestCase {
* @dataProvider providerUpdateGlobalLazy
*/
public function testUpdateGlobalLazy(bool $lazy): void {
- $preferences = $this->generateUserPreferences($preload ?? []);
+ $userConfig = $this->generateUserConfig($preload ?? []);
$app = 'app2';
if ($lazy) {
$key = 'key4';
@@ -1663,15 +1663,15 @@ class UserPreferencesTest extends TestCase {
$value = 'value3';
}
- $this->assertEquals($value, $preferences->getValueString('user1', $app, $key, '', !$lazy));
+ $this->assertEquals($value, $userConfig->getValueString('user1', $app, $key, '', !$lazy));
foreach (['user1', 'user2', 'user3', 'user4'] as $userId) {
- $this->assertEquals(!$lazy, $preferences->isLazy($userId, $app, $key));
+ $this->assertEquals(!$lazy, $userConfig->isLazy($userId, $app, $key));
}
- $preferences->updateGlobalLazy($app, $key, $lazy);
- $this->assertEquals($value, $preferences->getValueString('user1', $app, $key, '', $lazy));
+ $userConfig->updateGlobalLazy($app, $key, $lazy);
+ $this->assertEquals($value, $userConfig->getValueString('user1', $app, $key, '', $lazy));
foreach (['user1', 'user2', 'user3', 'user4'] as $userId) {
- $this->assertEquals($lazy, $preferences->isLazy($userId, $app, $key));
+ $this->assertEquals($lazy, $userConfig->isLazy($userId, $app, $key));
}
}
@@ -1723,8 +1723,8 @@ class UserPreferencesTest extends TestCase {
* @dataProvider providerGetDetails
*/
public function testGetDetails(string $userId, string $app, string $key, array $result): void {
- $preferences = $this->generateUserPreferences($preload ?? []);
- $this->assertEqualsCanonicalizing($result, $preferences->getDetails($userId, $app, $key));
+ $userConfig = $this->generateUserConfig($preload ?? []);
+ $this->assertEqualsCanonicalizing($result, $userConfig->getDetails($userId, $app, $key));
}
@@ -1748,15 +1748,15 @@ class UserPreferencesTest extends TestCase {
string $app,
string $key,
): void {
- $preferences = $this->generateUserPreferences($preload ?? []);
- $lazy = $preferences->isLazy($userId, $app, $key);
+ $userConfig = $this->generateUserConfig($preload ?? []);
+ $lazy = $userConfig->isLazy($userId, $app, $key);
- $preferences = $this->generateUserPreferences($preload ?? []);
- $this->assertEquals(true, $preferences->hasKey($userId, $app, $key, $lazy));
- $preferences->deletePreference($userId, $app, $key);
- $this->assertEquals(false, $preferences->hasKey($userId, $app, $key, $lazy));
- $preferences = $this->generateUserPreferences($preload ?? []);
- $this->assertEquals(false, $preferences->hasKey($userId, $app, $key, $lazy));
+ $userConfig = $this->generateUserConfig($preload ?? []);
+ $this->assertEquals(true, $userConfig->hasKey($userId, $app, $key, $lazy));
+ $userConfig->deleteUserConfig($userId, $app, $key);
+ $this->assertEquals(false, $userConfig->hasKey($userId, $app, $key, $lazy));
+ $userConfig = $this->generateUserConfig($preload ?? []);
+ $this->assertEquals(false, $userConfig->hasKey($userId, $app, $key, $lazy));
}
public function providerDeleteKey(): array {
@@ -1778,50 +1778,50 @@ class UserPreferencesTest extends TestCase {
string $app,
string $key,
): void {
- $preferences = $this->generateUserPreferences($preload ?? []);
- $preferences->deleteKey($app, $key);
+ $userConfig = $this->generateUserConfig($preload ?? []);
+ $userConfig->deleteKey($app, $key);
foreach (['user1', 'user2', 'user3', 'user4'] as $userId) {
- $this->assertEquals(false, $preferences->hasKey($userId, $app, $key, null));
- $preferencesTemp = $this->generateUserPreferences($preload ?? []);
- $this->assertEquals(false, $preferencesTemp->hasKey($userId, $app, $key, null));
+ $this->assertEquals(false, $userConfig->hasKey($userId, $app, $key, null));
+ $userConfigTemp = $this->generateUserConfig($preload ?? []);
+ $this->assertEquals(false, $userConfigTemp->hasKey($userId, $app, $key, null));
}
}
public function testDeleteApp(): void {
- $preferences = $this->generateUserPreferences();
- $preferences->deleteApp('only-lazy');
+ $userConfig = $this->generateUserConfig();
+ $userConfig->deleteApp('only-lazy');
foreach (['user1', 'user2', 'user3', 'user4'] as $userId) {
- $this->assertEquals(false, in_array('only-lazy', $preferences->getApps($userId)));
- $preferencesTemp = $this->generateUserPreferences();
- $this->assertEquals(false, in_array('only-lazy', $preferencesTemp->getApps($userId)));
+ $this->assertEquals(false, in_array('only-lazy', $userConfig->getApps($userId)));
+ $userConfigTemp = $this->generateUserConfig();
+ $this->assertEquals(false, in_array('only-lazy', $userConfigTemp->getApps($userId)));
}
}
public function testDeleteAllPreferences(): void {
- $preferences = $this->generateUserPreferences();
- $preferences->deleteAllPreferences('user1');
+ $userConfig = $this->generateUserConfig();
+ $userConfig->deleteAllUserConfig('user1');
- $this->assertEqualsCanonicalizing([], $preferences->getApps('user1'));
- $preferences = $this->generateUserPreferences();
- $this->assertEqualsCanonicalizing([], $preferences->getApps('user1'));
+ $this->assertEqualsCanonicalizing([], $userConfig->getApps('user1'));
+ $userConfig = $this->generateUserConfig();
+ $this->assertEqualsCanonicalizing([], $userConfig->getApps('user1'));
}
public function testClearCache(): void {
- $preferences = $this->generateUserPreferences(['user1', 'user2']);
- $preferences->clearCache('user1');
+ $userConfig = $this->generateUserConfig(['user1', 'user2']);
+ $userConfig->clearCache('user1');
- $this->assertEquals(true, $preferences->statusCache()['fastLoaded']['user2']);
- $this->assertEquals(false, $preferences->statusCache()['fastLoaded']['user1']);
- $this->assertEquals('value2a', $preferences->getValueString('user1', 'app2', 'key2'));
- $this->assertEquals(false, $preferences->statusCache()['lazyLoaded']['user1']);
- $this->assertEquals(true, $preferences->statusCache()['fastLoaded']['user1']);
+ $this->assertEquals(true, $userConfig->statusCache()['fastLoaded']['user2']);
+ $this->assertEquals(false, $userConfig->statusCache()['fastLoaded']['user1']);
+ $this->assertEquals('value2a', $userConfig->getValueString('user1', 'app2', 'key2'));
+ $this->assertEquals(false, $userConfig->statusCache()['lazyLoaded']['user1']);
+ $this->assertEquals(true, $userConfig->statusCache()['fastLoaded']['user1']);
}
public function testClearCacheAll(): void {
- $preferences = $this->generateUserPreferences(['user1', 'user2']);
- $preferences->clearCacheAll();
+ $userConfig = $this->generateUserConfig(['user1', 'user2']);
+ $userConfig->clearCacheAll();
$this->assertEqualsCanonicalizing(
[
'fastLoaded' => [],
@@ -1830,7 +1830,7 @@ class UserPreferencesTest extends TestCase {
'lazyCache' => [],
'valueTypes' => [],
],
- $preferences->statusCache()
+ $userConfig->statusCache()
);
}
}