]> source.dussan.org Git - nextcloud-server.git/commitdiff
Fix types for reading and writing config values 37507/head
authorjld3103 <jld3103yt@gmail.com>
Fri, 31 Mar 2023 06:53:56 +0000 (08:53 +0200)
committerjld3103 <jld3103yt@gmail.com>
Wed, 5 Apr 2023 07:08:56 +0000 (09:08 +0200)
Signed-off-by: jld3103 <jld3103yt@gmail.com>
15 files changed:
apps/settings/lib/Controller/CheckSetupController.php
apps/settings/lib/Settings/Admin/Sharing.php
apps/settings/tests/Settings/Admin/SharingTest.php
apps/updatenotification/lib/Controller/AdminController.php
apps/updatenotification/lib/Notification/BackgroundJob.php
apps/updatenotification/lib/Notification/Notifier.php
apps/updatenotification/lib/Settings/Admin.php
apps/user_ldap/lib/Jobs/Sync.php
apps/user_ldap/lib/User/User.php
lib/private/Authentication/TwoFactorAuth/Manager.php
lib/private/Setup.php
lib/private/Share20/Manager.php
lib/private/Updater/VersionCheck.php
tests/lib/Share20/ManagerTest.php
tests/lib/Updater/VersionCheckTest.php

index 82a7e118d064937d2456044b26d3f21f4e60243d..81a112cac55fbdba2a22b2c2d68d78937d3224b4 100644 (file)
@@ -632,7 +632,7 @@ Raw output
        }
 
        protected function getLastCronInfo(): array {
-               $lastCronRun = $this->config->getAppValue('core', 'lastcron', 0);
+               $lastCronRun = (int)$this->config->getAppValue('core', 'lastcron', '0');
                return [
                        'diffInSeconds' => time() - $lastCronRun,
                        'relativeTime' => $this->dateTimeFormatter->formatTimeSpan($lastCronRun),
index d3c6839b8f7618d32e582634b33d3c5f4ad2df73..32b09f333a9c66b21d7e0be56dc59846066be667 100644 (file)
@@ -104,7 +104,7 @@ class Sharing implements IDelegatedSettings {
                        'shareExcludedGroupsList' => $excludeGroupsList,
                        'publicShareDisclaimerText' => $this->config->getAppValue('core', 'shareapi_public_link_disclaimertext', null),
                        'enableLinkPasswordByDefault' => $this->config->getAppValue('core', 'shareapi_enable_link_password_by_default', 'no'),
-                       'shareApiDefaultPermissions' => $this->config->getAppValue('core', 'shareapi_default_permissions', Constants::PERMISSION_ALL),
+                       'shareApiDefaultPermissions' => (int)$this->config->getAppValue('core', 'shareapi_default_permissions', (string)Constants::PERMISSION_ALL),
                        'shareApiDefaultPermissionsCheckboxes' => $this->getSharePermissionList(),
                        'shareDefaultInternalExpireDateSet' => $this->config->getAppValue('core', 'shareapi_default_internal_expire_date', 'no'),
                        'shareInternalExpireAfterNDays' => $this->config->getAppValue('core', 'shareapi_internal_expire_after_n_days', '7'),
index 2468ad97d1ea9f91e64e2c9cf6ac8dda810823ef..c0b5861f549e5e2cca219d53eb3ea4824194ee04 100644 (file)
@@ -93,7 +93,7 @@ class SharingTest extends TestCase {
                                ['core', 'shareapi_exclude_groups', 'no', 'no'],
                                ['core', 'shareapi_public_link_disclaimertext', null, 'Lorem ipsum'],
                                ['core', 'shareapi_enable_link_password_by_default', 'no', 'yes'],
-                               ['core', 'shareapi_default_permissions', Constants::PERMISSION_ALL, Constants::PERMISSION_ALL],
+                               ['core', 'shareapi_default_permissions', (string)Constants::PERMISSION_ALL, Constants::PERMISSION_ALL],
                                ['core', 'shareapi_default_internal_expire_date', 'no', 'no'],
                                ['core', 'shareapi_internal_expire_after_n_days', '7', '7'],
                                ['core', 'shareapi_enforce_internal_expire_date', 'no', 'no'],
@@ -175,7 +175,7 @@ class SharingTest extends TestCase {
                                ['core', 'shareapi_exclude_groups', 'no', 'yes'],
                                ['core', 'shareapi_public_link_disclaimertext', null, 'Lorem ipsum'],
                                ['core', 'shareapi_enable_link_password_by_default', 'no', 'yes'],
-                               ['core', 'shareapi_default_permissions', Constants::PERMISSION_ALL, Constants::PERMISSION_ALL],
+                               ['core', 'shareapi_default_permissions', (string)Constants::PERMISSION_ALL, Constants::PERMISSION_ALL],
                                ['core', 'shareapi_default_internal_expire_date', 'no', 'no'],
                                ['core', 'shareapi_internal_expire_after_n_days', '7', '7'],
                                ['core', 'shareapi_enforce_internal_expire_date', 'no', 'no'],
index b13ba66efd573cde7b4524cd0105c65dc7ed4e11..74a3a86c7e1e5351800df628980b7321c4b7549c 100644 (file)
@@ -85,7 +85,7 @@ class AdminController extends Controller {
         */
        public function setChannel(string $channel): DataResponse {
                Util::setChannel($channel);
-               $this->config->setAppValue('core', 'lastupdatedat', 0);
+               $this->config->setAppValue('core', 'lastupdatedat', '0');
                return new DataResponse(['status' => 'success', 'data' => ['message' => $this->l10n->t('Channel updated')]]);
        }
 
@@ -99,7 +99,7 @@ class AdminController extends Controller {
 
                // Create a new job and store the creation date
                $this->jobList->add(ResetTokenBackgroundJob::class);
-               $this->config->setAppValue('core', 'updater.secret.created', $this->timeFactory->getTime());
+               $this->config->setAppValue('core', 'updater.secret.created', (string)$this->timeFactory->getTime());
 
                // Create a new token
                $newToken = $this->secureRandom->generate(64);
index c1b3cddf945397f128b8040b902c37c198a7b11e..f8f1f41e589ef777eac97a396a19f267d0a9a23f 100644 (file)
@@ -108,14 +108,14 @@ class BackgroundJob extends TimedJob {
 
                $status = $updater->check();
                if ($status === false) {
-                       $errors = 1 + (int) $this->config->getAppValue('updatenotification', 'update_check_errors', 0);
-                       $this->config->setAppValue('updatenotification', 'update_check_errors', $errors);
+                       $errors = 1 + (int) $this->config->getAppValue('updatenotification', 'update_check_errors', '0');
+                       $this->config->setAppValue('updatenotification', 'update_check_errors', (string)$errors);
 
                        if (\in_array($errors, $this->connectionNotifications, true)) {
                                $this->sendErrorNotifications($errors);
                        }
                } elseif (\is_array($status)) {
-                       $this->config->setAppValue('updatenotification', 'update_check_errors', 0);
+                       $this->config->setAppValue('updatenotification', 'update_check_errors', '0');
                        $this->clearErrorNotifications();
 
                        if (isset($status['version'])) {
index c1269daaa304dd5a8d5b7af8a12543ceb6c18f6c..9ce233ed72131fd52ffffe529e88f0a48d86184f 100644 (file)
@@ -115,7 +115,7 @@ class Notifier implements INotifier {
 
                $l = $this->l10NFactory->get('updatenotification', $languageCode);
                if ($notification->getSubject() === 'connection_error') {
-                       $errors = (int) $this->config->getAppValue('updatenotification', 'update_check_errors', 0);
+                       $errors = (int) $this->config->getAppValue('updatenotification', 'update_check_errors', '0');
                        if ($errors === 0) {
                                $this->notificationManager->markProcessed($notification);
                                throw new \InvalidArgumentException('Update checked worked again');
index fded44514083a71a5379b8bc99dd4647918ebd3d..7f47a46f8f95ebc7af6b7aeb195d596ae7d3006e 100644 (file)
@@ -78,7 +78,7 @@ class Admin implements ISettings {
        }
 
        public function getForm(): TemplateResponse {
-               $lastUpdateCheckTimestamp = $this->config->getAppValue('core', 'lastupdatedat');
+               $lastUpdateCheckTimestamp = (int)$this->config->getAppValue('core', 'lastupdatedat');
                $lastUpdateCheck = $this->dateTimeFormatter->formatDateTime($lastUpdateCheckTimestamp);
 
                $channels = [
index b231089b79b1fecd51078d3c464d15ad87833a5e..1ba24af5399b66b1f840f743e57d5ce893397d45 100644 (file)
@@ -73,10 +73,10 @@ class Sync extends TimedJob {
                parent::__construct($time);
                $this->userManager = $userManager;
                $this->setInterval(
-                       \OC::$server->getConfig()->getAppValue(
+                       (int)\OC::$server->getConfig()->getAppValue(
                                'user_ldap',
                                'background_sync_interval',
-                               self::MIN_INTERVAL
+                               (string)self::MIN_INTERVAL
                        )
                );
        }
@@ -97,7 +97,7 @@ class Sync extends TimedJob {
                $interval = floor(24 * 60 * 60 / $runsPerDay);
                $interval = min(max($interval, self::MIN_INTERVAL), self::MAX_INTERVAL);
 
-               $this->config->setAppValue('user_ldap', 'background_sync_interval', $interval);
+               $this->config->setAppValue('user_ldap', 'background_sync_interval', (string)$interval);
        }
 
        /**
@@ -198,7 +198,7 @@ class Sync extends TimedJob {
 
                $cycleData = [
                        'prefix' => $this->config->getAppValue('user_ldap', 'background_sync_prefix', null),
-                       'offset' => (int)$this->config->getAppValue('user_ldap', 'background_sync_offset', 0),
+                       'offset' => (int)$this->config->getAppValue('user_ldap', 'background_sync_offset', '0'),
                ];
 
                if (
@@ -255,7 +255,7 @@ class Sync extends TimedJob {
         * @return bool
         */
        public function qualifiesToRun($cycleData) {
-               $lastChange = $this->config->getAppValue('user_ldap', $cycleData['prefix'] . '_lastChange', 0);
+               $lastChange = (int)$this->config->getAppValue('user_ldap', $cycleData['prefix'] . '_lastChange', '0');
                if ((time() - $lastChange) > 60 * 30) {
                        return true;
                }
index 15894ce04b775df68a611b450386fcdffb452f24..edf43494777020031aaa20ddea4c538546396f21 100644 (file)
@@ -303,7 +303,7 @@ class User {
                }
 
                if (!is_null($attr)
-                       && $this->config->getAppValue('user_ldap', 'enforce_home_folder_naming_rule', true)
+                       && $this->config->getAppValue('user_ldap', 'enforce_home_folder_naming_rule', 'true')
                ) {
                        // a naming rule attribute is defined, but it doesn't exist for that LDAP user
                        throw new \Exception('Home dir attribute can\'t be read from LDAP for uid: ' . $this->getUsername());
@@ -355,7 +355,7 @@ class User {
         */
        public function markLogin() {
                $this->config->setUserValue(
-                       $this->uid, 'user_ldap', self::USER_PREFKEY_FIRSTLOGIN, 1);
+                       $this->uid, 'user_ldap', self::USER_PREFKEY_FIRSTLOGIN, '1');
        }
 
        /**
index d62556465df82a898287ed6f8b418974426ade2c..7e115cf9b4221e931978e21a462ae4ae31f33608 100644 (file)
@@ -280,7 +280,7 @@ class Manager {
                        $sessionId = $this->session->getId();
                        $token = $this->tokenProvider->getToken($sessionId);
                        $tokenId = $token->getId();
-                       $this->config->deleteUserValue($user->getUID(), 'login_token_2fa', $tokenId);
+                       $this->config->deleteUserValue($user->getUID(), 'login_token_2fa', (string)$tokenId);
 
                        $dispatchEvent = new GenericEvent($user, ['provider' => $provider->getDisplayName()]);
                        $this->legacyDispatcher->dispatch(IProvider::EVENT_SUCCESS, $dispatchEvent);
@@ -395,7 +395,7 @@ class Manager {
 
                $id = $this->session->getId();
                $token = $this->tokenProvider->getToken($id);
-               $this->config->setUserValue($user->getUID(), 'login_token_2fa', (string) $token->getId(), $this->timeFactory->getTime());
+               $this->config->setUserValue($user->getUID(), 'login_token_2fa', (string) $token->getId(), (string)$this->timeFactory->getTime());
        }
 
        public function clearTwoFactorPending(string $userId) {
index dc59eacbf5717ee2c57fa1b8df16906c07fc87a8..e8371ba85425b96014e1c5582de204c833414651 100644 (file)
@@ -391,8 +391,8 @@ class Setup {
 
                if (empty($error)) {
                        $config = \OC::$server->getConfig();
-                       $config->setAppValue('core', 'installedat', microtime(true));
-                       $config->setAppValue('core', 'lastupdatedat', microtime(true));
+                       $config->setAppValue('core', 'installedat', (string)microtime(true));
+                       $config->setAppValue('core', 'lastupdatedat', (string)microtime(true));
 
                        $vendorData = $this->getVendorData();
                        $config->setAppValue('core', 'vendor', $vendorData['vendor']);
index 1661b1d6a61bd0e929b44dc6b2cac767a1745ea9..26e5549ccffdc7116339d18600b78cc82d47b1cd 100644 (file)
@@ -494,7 +494,7 @@ class Manager implements IManager {
                        $expirationDate = new \DateTime();
                        $expirationDate->setTime(0, 0, 0);
 
-                       $days = (int)$this->config->getAppValue('core', 'link_defaultExpDays', $this->shareApiLinkDefaultExpireDays());
+                       $days = (int)$this->config->getAppValue('core', 'link_defaultExpDays', (string)$this->shareApiLinkDefaultExpireDays());
                        if ($days > $this->shareApiLinkDefaultExpireDays()) {
                                $days = $this->shareApiLinkDefaultExpireDays();
                        }
index 3abbae682b595861c836a9b2410a55c188d9cae0..156d1c2e02f820af5ac10548cbd729ec7c26d09c 100644 (file)
@@ -66,10 +66,10 @@ class VersionCheck {
 
                $updaterUrl = $this->config->getSystemValue('updater.server.url', 'https://updates.nextcloud.com/updater_server/');
 
-               $this->config->setAppValue('core', 'lastupdatedat', time());
+               $this->config->setAppValue('core', 'lastupdatedat', (string)time());
 
                if ($this->config->getAppValue('core', 'installedat', '') === '') {
-                       $this->config->setAppValue('core', 'installedat', microtime(true));
+                       $this->config->setAppValue('core', 'installedat', (string)microtime(true));
                }
 
                $version = Util::getVersion();
index 36680b7b926b544c3bf954839ecffd3f3d42bcfc..0e56592e1a524f59402abe7f48d075e53a6d6dc2 100644 (file)
@@ -1285,7 +1285,7 @@ class ManagerTest extends \Test\TestCase {
                                ['core', 'shareapi_enforce_expire_date', 'no', 'yes'],
                                ['core', 'shareapi_expire_after_n_days', '7', '3'],
                                ['core', 'shareapi_default_expire_date', 'no', 'yes'],
-                               ['core', 'link_defaultExpDays', 3, '3'],
+                               ['core', 'link_defaultExpDays', '3', '3'],
                        ]);
 
                $expected = new \DateTime();
@@ -1306,7 +1306,7 @@ class ManagerTest extends \Test\TestCase {
                                ['core', 'shareapi_enforce_expire_date', 'no', 'yes'],
                                ['core', 'shareapi_expire_after_n_days', '7', '3'],
                                ['core', 'shareapi_default_expire_date', 'no', 'yes'],
-                               ['core', 'link_defaultExpDays', 3, '1'],
+                               ['core', 'link_defaultExpDays', '3', '1'],
                        ]);
 
                $expected = new \DateTime();
@@ -1416,7 +1416,7 @@ class ManagerTest extends \Test\TestCase {
                        ->willReturnMap([
                                ['core', 'shareapi_default_expire_date', 'no', 'yes'],
                                ['core', 'shareapi_expire_after_n_days', '7', '3'],
-                               ['core', 'link_defaultExpDays', 3, '3'],
+                               ['core', 'link_defaultExpDays', '3', '3'],
                        ]);
 
                $hookListener = $this->getMockBuilder('Dummy')->setMethods(['listener'])->getMock();
@@ -1445,7 +1445,7 @@ class ManagerTest extends \Test\TestCase {
                        ->willReturnMap([
                                ['core', 'shareapi_default_expire_date', 'no', 'yes'],
                                ['core', 'shareapi_expire_after_n_days', '7', '3'],
-                               ['core', 'link_defaultExpDays', 3, '1'],
+                               ['core', 'link_defaultExpDays', '3', '1'],
                        ]);
 
                $hookListener = $this->getMockBuilder('Dummy')->setMethods(['listener'])->getMock();
index cc2b0a369aae6893651188a917c3e2174eea1201..85c74db2ca6857f254a899f65b25b8cb6cdfda94 100644 (file)
@@ -111,7 +111,7 @@ class VersionCheckTest extends \Test\TestCase {
                                ['core', 'lastupdatedat'],
                        )
                        ->willReturnOnConsecutiveCalls(
-                               0,
+                               '0',
                                'installedat',
                                'installedat',
                                'lastupdatedat'
@@ -125,7 +125,7 @@ class VersionCheckTest extends \Test\TestCase {
                        ->expects($this->exactly(2))
                        ->method('setAppValue')
                        ->withConsecutive(
-                               ['core', 'lastupdatedat', $this->isType('integer')],
+                               ['core', 'lastupdatedat', $this->isType('string')],
                                ['core', 'lastupdateResult', json_encode($expectedResult)]
                        );
 
@@ -163,7 +163,7 @@ class VersionCheckTest extends \Test\TestCase {
                                ['core', 'lastupdatedat'],
                        )
                        ->willReturnOnConsecutiveCalls(
-                               0,
+                               '0',
                                'installedat',
                                'installedat',
                                'lastupdatedat'
@@ -177,7 +177,7 @@ class VersionCheckTest extends \Test\TestCase {
                        ->expects($this->exactly(2))
                        ->method('setAppValue')
                        ->withConsecutive(
-                               ['core', 'lastupdatedat', $this->isType('integer')],
+                               ['core', 'lastupdatedat', $this->isType('string')],
                                ['core', 'lastupdateResult', '[]']
                        );
 
@@ -217,7 +217,7 @@ class VersionCheckTest extends \Test\TestCase {
                                ['core', 'lastupdatedat'],
                        )
                        ->willReturnOnConsecutiveCalls(
-                               0,
+                               '0',
                                'installedat',
                                'installedat',
                                'lastupdatedat'
@@ -231,7 +231,7 @@ class VersionCheckTest extends \Test\TestCase {
                        ->expects($this->exactly(2))
                        ->method('setAppValue')
                        ->withConsecutive(
-                               ['core', 'lastupdatedat', $this->isType('integer')],
+                               ['core', 'lastupdatedat', $this->isType('string')],
                                ['core', 'lastupdateResult', $this->isType('string')]
                        );
 
@@ -270,7 +270,7 @@ class VersionCheckTest extends \Test\TestCase {
                                ['core', 'lastupdatedat'],
                        )
                        ->willReturnOnConsecutiveCalls(
-                               0,
+                               '0',
                                'installedat',
                                'installedat',
                                'lastupdatedat'
@@ -284,7 +284,7 @@ class VersionCheckTest extends \Test\TestCase {
                        ->expects($this->exactly(2))
                        ->method('setAppValue')
                        ->withConsecutive(
-                               ['core', 'lastupdatedat', $this->isType('integer')],
+                               ['core', 'lastupdatedat', $this->isType('string')],
                                ['core', 'lastupdateResult', json_encode($expectedResult)]
                        );
 
@@ -324,7 +324,7 @@ class VersionCheckTest extends \Test\TestCase {
                                ['core', 'lastupdatedat'],
                        )
                        ->willReturnOnConsecutiveCalls(
-                               0,
+                               '0',
                                'installedat',
                                'installedat',
                                'lastupdatedat'
@@ -338,7 +338,7 @@ class VersionCheckTest extends \Test\TestCase {
                        ->expects($this->exactly(2))
                        ->method('setAppValue')
                        ->withConsecutive(
-                               ['core', 'lastupdatedat', $this->isType('integer')],
+                               ['core', 'lastupdatedat', $this->isType('string')],
                                ['core', 'lastupdateResult', $this->isType('string')]
                        );