Skip to content

Commit c8b5562

Browse files
committed
fix(lexicon): renaming and minor fixes
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
1 parent c861003 commit c8b5562

File tree

5 files changed

+15
-19
lines changed

5 files changed

+15
-19
lines changed

lib/private/AppConfig.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ private function getTypedValue(
436436
int $type,
437437
): string {
438438
$this->assertParams($app, $key, valueType: $type);
439-
if (!$this->compareRegisteredConfigValues($app, $key, $lazy, $type, $default)) {
439+
if (!$this->matchAndApplyLexiconDefinition($app, $key, $lazy, $type, $default)) {
440440
return $default; // returns default if strictness of lexicon is set to WARNING (block and report)
441441
}
442442
$this->loadConfig($app, $lazy);
@@ -730,7 +730,7 @@ private function setTypedValue(
730730
int $type,
731731
): bool {
732732
$this->assertParams($app, $key);
733-
if (!$this->compareRegisteredConfigValues($app, $key, $lazy, $type)) {
733+
if (!$this->matchAndApplyLexiconDefinition($app, $key, $lazy, $type)) {
734734
return false; // returns false as database is not updated
735735
}
736736
$this->loadConfig(null, $lazy);
@@ -1573,13 +1573,13 @@ public function clearCachedConfig(): void {
15731573
}
15741574

15751575
/**
1576-
* verify and compare current use of config values with defined lexicon
1576+
* match and apply current use of config values with defined lexicon
15771577
*
15781578
* @throws AppConfigUnknownKeyException
15791579
* @throws AppConfigTypeConflictException
15801580
* @return bool TRUE if everything is fine compared to lexicon or lexicon does not exist
15811581
*/
1582-
private function compareRegisteredConfigValues(
1582+
private function matchAndApplyLexiconDefinition(
15831583
string $app,
15841584
string $key,
15851585
bool &$lazy,

lib/private/Config/UserConfig.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,7 @@ private function getTypedValue(
711711
ValueType $type,
712712
): string {
713713
$this->assertParams($userId, $app, $key);
714-
if (!$this->compareRegisteredConfigValues($app, $key, $lazy, $type, default: $default)) {
714+
if (!$this->matchAndApplyLexiconDefinition($app, $key, $lazy, $type, default: $default)) {
715715
return $default; // returns default if strictness of lexicon is set to WARNING (block and report)
716716
}
717717
$this->loadConfig($userId, $lazy);
@@ -1046,7 +1046,7 @@ private function setTypedValue(
10461046
ValueType $type,
10471047
): bool {
10481048
$this->assertParams($userId, $app, $key);
1049-
if (!$this->compareRegisteredConfigValues($app, $key, $lazy, $type, $flags)) {
1049+
if (!$this->matchAndApplyLexiconDefinition($app, $key, $lazy, $type, $flags)) {
10501050
return false; // returns false as database is not updated
10511051
}
10521052
$this->loadConfig($userId, $lazy);
@@ -1816,12 +1816,12 @@ private function decryptSensitiveValue(string $userId, string $app, string $key,
18161816
}
18171817

18181818
/**
1819-
* verify and compare current use of config values with defined lexicon
1819+
* match and apply current use of config values with defined lexicon
18201820
*
18211821
* @throws UnknownKeyException
18221822
* @throws TypeConflictException
18231823
*/
1824-
private function compareRegisteredConfigValues(
1824+
private function matchAndApplyLexiconDefinition(
18251825
string $app,
18261826
string $key,
18271827
bool &$lazy,
@@ -1837,7 +1837,7 @@ private function compareRegisteredConfigValues(
18371837
/** @var ConfigLexiconEntry $configValue */
18381838
$configValue = $configDetails['entries'][$key];
18391839
if ($type === ValueType::MIXED) {
1840-
$type = $configValue->getValueType()->value; // we overwrite if value was requested as mixed
1840+
$type = $configValue->getValueType(); // we overwrite if value was requested as mixed
18411841
} elseif ($configValue->getValueType() !== $type) {
18421842
throw new TypeConflictException('The user config key ' . $app . '/' . $key . ' is typed incorrectly in relation to the config lexicon');
18431843
}

lib/unstable/Config/Lexicon/ConfigLexiconEntry.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ public function getFlags(): int {
174174
* @experimental 31.0.0
175175
*/
176176
public function isFlagged(int $flag): bool {
177-
return (bool)($flag & $this->getFlags());
177+
return (($flag & $this->getFlags()) === $flag);
178178
}
179179

180180
/**

lib/unstable/Config/Lexicon/ConfigLexiconStrictness.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@
1818
*
1919
* @experimental 31.0.0
2020
*/
21-
enum ConfigLexiconStrictness: int {
21+
enum ConfigLexiconStrictness {
2222
/** @experimental 31.0.0 */
23-
case IGNORE = 0; // fully ignore
23+
case IGNORE; // fully ignore
2424
/** @experimental 31.0.0 */
25-
case NOTICE = 2; // ignore and report
25+
case NOTICE; // ignore and report
2626
/** @experimental 31.0.0 */
27-
case WARNING = 3; // silently block (returns $default) and report
27+
case WARNING; // silently block (returns $default) and report
2828
/** @experimental 31.0.0 */
29-
case EXCEPTION = 5; // block (throws exception) and report
29+
case EXCEPTION; // block (throws exception) and report
3030
}

tests/lib/AppConfigTest.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
use InvalidArgumentException;
1111
use OC\AppConfig;
12-
use OC\AppFramework\Bootstrap\Coordinator;
1312
use OCP\Exceptions\AppConfigTypeConflictException;
1413
use OCP\Exceptions\AppConfigUnknownKeyException;
1514
use OCP\IAppConfig;
@@ -29,7 +28,6 @@ class AppConfigTest extends TestCase {
2928
protected IDBConnection $connection;
3029
private LoggerInterface $logger;
3130
private ICrypto $crypto;
32-
private Coordinator $coordinator;
3331

3432
private array $originalConfig;
3533

@@ -91,7 +89,6 @@ protected function setUp(): void {
9189
$this->connection = \OCP\Server::get(IDBConnection::class);
9290
$this->logger = \OCP\Server::get(LoggerInterface::class);
9391
$this->crypto = \OCP\Server::get(ICrypto::class);
94-
$this->coordinator = \OCP\Server::get(Coordinator::class);
9592

9693
// storing current config and emptying the data table
9794
$sql = $this->connection->getQueryBuilder();
@@ -182,7 +179,6 @@ private function generateAppConfig(bool $preLoading = true): IAppConfig {
182179
$this->connection,
183180
$this->logger,
184181
$this->crypto,
185-
$this->coordinator
186182
);
187183
$msg = ' generateAppConfig() failed to confirm cache status';
188184

0 commit comments

Comments
 (0)