Skip to content

Commit 88ab6d4

Browse files
Merge pull request #37507 from nextcloud/fix/config-values-types
Fix types for reading and writing config values
2 parents 54140dd + d9f8522 commit 88ab6d4

File tree

15 files changed

+39
-39
lines changed

15 files changed

+39
-39
lines changed

apps/settings/lib/Controller/CheckSetupController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,7 @@ protected function getSuggestedOverwriteCliURL(): string {
632632
}
633633

634634
protected function getLastCronInfo(): array {
635-
$lastCronRun = $this->config->getAppValue('core', 'lastcron', 0);
635+
$lastCronRun = (int)$this->config->getAppValue('core', 'lastcron', '0');
636636
return [
637637
'diffInSeconds' => time() - $lastCronRun,
638638
'relativeTime' => $this->dateTimeFormatter->formatTimeSpan($lastCronRun),

apps/settings/lib/Settings/Admin/Sharing.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public function getForm() {
104104
'shareExcludedGroupsList' => $excludeGroupsList,
105105
'publicShareDisclaimerText' => $this->config->getAppValue('core', 'shareapi_public_link_disclaimertext', null),
106106
'enableLinkPasswordByDefault' => $this->config->getAppValue('core', 'shareapi_enable_link_password_by_default', 'no'),
107-
'shareApiDefaultPermissions' => $this->config->getAppValue('core', 'shareapi_default_permissions', Constants::PERMISSION_ALL),
107+
'shareApiDefaultPermissions' => (int)$this->config->getAppValue('core', 'shareapi_default_permissions', (string)Constants::PERMISSION_ALL),
108108
'shareApiDefaultPermissionsCheckboxes' => $this->getSharePermissionList(),
109109
'shareDefaultInternalExpireDateSet' => $this->config->getAppValue('core', 'shareapi_default_internal_expire_date', 'no'),
110110
'shareInternalExpireAfterNDays' => $this->config->getAppValue('core', 'shareapi_internal_expire_after_n_days', '7'),

apps/settings/tests/Settings/Admin/SharingTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public function testGetFormWithoutExcludedGroups(): void {
9393
['core', 'shareapi_exclude_groups', 'no', 'no'],
9494
['core', 'shareapi_public_link_disclaimertext', null, 'Lorem ipsum'],
9595
['core', 'shareapi_enable_link_password_by_default', 'no', 'yes'],
96-
['core', 'shareapi_default_permissions', Constants::PERMISSION_ALL, Constants::PERMISSION_ALL],
96+
['core', 'shareapi_default_permissions', (string)Constants::PERMISSION_ALL, Constants::PERMISSION_ALL],
9797
['core', 'shareapi_default_internal_expire_date', 'no', 'no'],
9898
['core', 'shareapi_internal_expire_after_n_days', '7', '7'],
9999
['core', 'shareapi_enforce_internal_expire_date', 'no', 'no'],
@@ -175,7 +175,7 @@ public function testGetFormWithExcludedGroups(): void {
175175
['core', 'shareapi_exclude_groups', 'no', 'yes'],
176176
['core', 'shareapi_public_link_disclaimertext', null, 'Lorem ipsum'],
177177
['core', 'shareapi_enable_link_password_by_default', 'no', 'yes'],
178-
['core', 'shareapi_default_permissions', Constants::PERMISSION_ALL, Constants::PERMISSION_ALL],
178+
['core', 'shareapi_default_permissions', (string)Constants::PERMISSION_ALL, Constants::PERMISSION_ALL],
179179
['core', 'shareapi_default_internal_expire_date', 'no', 'no'],
180180
['core', 'shareapi_internal_expire_after_n_days', '7', '7'],
181181
['core', 'shareapi_enforce_internal_expire_date', 'no', 'no'],

apps/updatenotification/lib/Controller/AdminController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ private function isUpdaterEnabled() {
8585
*/
8686
public function setChannel(string $channel): DataResponse {
8787
Util::setChannel($channel);
88-
$this->config->setAppValue('core', 'lastupdatedat', 0);
88+
$this->config->setAppValue('core', 'lastupdatedat', '0');
8989
return new DataResponse(['status' => 'success', 'data' => ['message' => $this->l10n->t('Channel updated')]]);
9090
}
9191

@@ -99,7 +99,7 @@ public function createCredentials(): DataResponse {
9999

100100
// Create a new job and store the creation date
101101
$this->jobList->add(ResetTokenBackgroundJob::class);
102-
$this->config->setAppValue('core', 'updater.secret.created', $this->timeFactory->getTime());
102+
$this->config->setAppValue('core', 'updater.secret.created', (string)$this->timeFactory->getTime());
103103

104104
// Create a new token
105105
$newToken = $this->secureRandom->generate(64);

apps/updatenotification/lib/Notification/BackgroundJob.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,14 +108,14 @@ protected function checkCoreUpdate() {
108108

109109
$status = $updater->check();
110110
if ($status === false) {
111-
$errors = 1 + (int) $this->config->getAppValue('updatenotification', 'update_check_errors', 0);
112-
$this->config->setAppValue('updatenotification', 'update_check_errors', $errors);
111+
$errors = 1 + (int) $this->config->getAppValue('updatenotification', 'update_check_errors', '0');
112+
$this->config->setAppValue('updatenotification', 'update_check_errors', (string)$errors);
113113

114114
if (\in_array($errors, $this->connectionNotifications, true)) {
115115
$this->sendErrorNotifications($errors);
116116
}
117117
} elseif (\is_array($status)) {
118-
$this->config->setAppValue('updatenotification', 'update_check_errors', 0);
118+
$this->config->setAppValue('updatenotification', 'update_check_errors', '0');
119119
$this->clearErrorNotifications();
120120

121121
if (isset($status['version'])) {

apps/updatenotification/lib/Notification/Notifier.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public function prepare(INotification $notification, string $languageCode): INot
115115

116116
$l = $this->l10NFactory->get('updatenotification', $languageCode);
117117
if ($notification->getSubject() === 'connection_error') {
118-
$errors = (int) $this->config->getAppValue('updatenotification', 'update_check_errors', 0);
118+
$errors = (int) $this->config->getAppValue('updatenotification', 'update_check_errors', '0');
119119
if ($errors === 0) {
120120
$this->notificationManager->markProcessed($notification);
121121
throw new \InvalidArgumentException('Update checked worked again');

apps/updatenotification/lib/Settings/Admin.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function __construct(
7878
}
7979

8080
public function getForm(): TemplateResponse {
81-
$lastUpdateCheckTimestamp = $this->config->getAppValue('core', 'lastupdatedat');
81+
$lastUpdateCheckTimestamp = (int)$this->config->getAppValue('core', 'lastupdatedat');
8282
$lastUpdateCheck = $this->dateTimeFormatter->formatDateTime($lastUpdateCheckTimestamp);
8383

8484
$channels = [

apps/user_ldap/lib/Jobs/Sync.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,10 @@ public function __construct(Manager $userManager, ITimeFactory $time) {
7373
parent::__construct($time);
7474
$this->userManager = $userManager;
7575
$this->setInterval(
76-
\OC::$server->getConfig()->getAppValue(
76+
(int)\OC::$server->getConfig()->getAppValue(
7777
'user_ldap',
7878
'background_sync_interval',
79-
self::MIN_INTERVAL
79+
(string)self::MIN_INTERVAL
8080
)
8181
);
8282
}
@@ -97,7 +97,7 @@ public function updateInterval() {
9797
$interval = floor(24 * 60 * 60 / $runsPerDay);
9898
$interval = min(max($interval, self::MIN_INTERVAL), self::MAX_INTERVAL);
9999

100-
$this->config->setAppValue('user_ldap', 'background_sync_interval', $interval);
100+
$this->config->setAppValue('user_ldap', 'background_sync_interval', (string)$interval);
101101
}
102102

103103
/**
@@ -198,7 +198,7 @@ public function getCycle() {
198198

199199
$cycleData = [
200200
'prefix' => $this->config->getAppValue('user_ldap', 'background_sync_prefix', null),
201-
'offset' => (int)$this->config->getAppValue('user_ldap', 'background_sync_offset', 0),
201+
'offset' => (int)$this->config->getAppValue('user_ldap', 'background_sync_offset', '0'),
202202
];
203203

204204
if (
@@ -255,7 +255,7 @@ public function determineNextCycle(array $cycleData = null) {
255255
* @return bool
256256
*/
257257
public function qualifiesToRun($cycleData) {
258-
$lastChange = $this->config->getAppValue('user_ldap', $cycleData['prefix'] . '_lastChange', 0);
258+
$lastChange = (int)$this->config->getAppValue('user_ldap', $cycleData['prefix'] . '_lastChange', '0');
259259
if ((time() - $lastChange) > 60 * 30) {
260260
return true;
261261
}

apps/user_ldap/lib/User/User.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ public function getHomePath($valueFromLDAP = null) {
303303
}
304304

305305
if (!is_null($attr)
306-
&& $this->config->getAppValue('user_ldap', 'enforce_home_folder_naming_rule', true)
306+
&& $this->config->getAppValue('user_ldap', 'enforce_home_folder_naming_rule', 'true')
307307
) {
308308
// a naming rule attribute is defined, but it doesn't exist for that LDAP user
309309
throw new \Exception('Home dir attribute can\'t be read from LDAP for uid: ' . $this->getUsername());
@@ -355,7 +355,7 @@ public function getAvatarImage() {
355355
*/
356356
public function markLogin() {
357357
$this->config->setUserValue(
358-
$this->uid, 'user_ldap', self::USER_PREFKEY_FIRSTLOGIN, 1);
358+
$this->uid, 'user_ldap', self::USER_PREFKEY_FIRSTLOGIN, '1');
359359
}
360360

361361
/**

lib/private/Authentication/TwoFactorAuth/Manager.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ public function verifyChallenge(string $providerId, IUser $user, string $challen
280280
$sessionId = $this->session->getId();
281281
$token = $this->tokenProvider->getToken($sessionId);
282282
$tokenId = $token->getId();
283-
$this->config->deleteUserValue($user->getUID(), 'login_token_2fa', $tokenId);
283+
$this->config->deleteUserValue($user->getUID(), 'login_token_2fa', (string)$tokenId);
284284

285285
$dispatchEvent = new GenericEvent($user, ['provider' => $provider->getDisplayName()]);
286286
$this->legacyDispatcher->dispatch(IProvider::EVENT_SUCCESS, $dispatchEvent);
@@ -395,7 +395,7 @@ public function prepareTwoFactorLogin(IUser $user, bool $rememberMe) {
395395

396396
$id = $this->session->getId();
397397
$token = $this->tokenProvider->getToken($id);
398-
$this->config->setUserValue($user->getUID(), 'login_token_2fa', (string) $token->getId(), $this->timeFactory->getTime());
398+
$this->config->setUserValue($user->getUID(), 'login_token_2fa', (string) $token->getId(), (string)$this->timeFactory->getTime());
399399
}
400400

401401
public function clearTwoFactorPending(string $userId) {

0 commit comments

Comments
 (0)