Skip to content

Commit f1cc337

Browse files
committed
Migrate 32bit check to SetupCheck API
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
1 parent fe96eda commit f1cc337

File tree

8 files changed

+71
-99
lines changed

8 files changed

+71
-99
lines changed

apps/settings/composer/composer/autoload_classmap.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@
9090
'OCA\\Settings\\SetupChecks\\RandomnessSecure' => $baseDir . '/../lib/SetupChecks/RandomnessSecure.php',
9191
'OCA\\Settings\\SetupChecks\\ReadOnlyConfig' => $baseDir . '/../lib/SetupChecks/ReadOnlyConfig.php',
9292
'OCA\\Settings\\SetupChecks\\SupportedDatabase' => $baseDir . '/../lib/SetupChecks/SupportedDatabase.php',
93+
'OCA\\Settings\\SetupChecks\\SystemIs64bit' => $baseDir . '/../lib/SetupChecks/SystemIs64bit.php',
9394
'OCA\\Settings\\SetupChecks\\TransactionIsolation' => $baseDir . '/../lib/SetupChecks/TransactionIsolation.php',
9495
'OCA\\Settings\\UserMigration\\AccountMigrator' => $baseDir . '/../lib/UserMigration/AccountMigrator.php',
9596
'OCA\\Settings\\UserMigration\\AccountMigratorException' => $baseDir . '/../lib/UserMigration/AccountMigratorException.php',

apps/settings/composer/composer/autoload_static.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ class ComposerStaticInitSettings
105105
'OCA\\Settings\\SetupChecks\\RandomnessSecure' => __DIR__ . '/..' . '/../lib/SetupChecks/RandomnessSecure.php',
106106
'OCA\\Settings\\SetupChecks\\ReadOnlyConfig' => __DIR__ . '/..' . '/../lib/SetupChecks/ReadOnlyConfig.php',
107107
'OCA\\Settings\\SetupChecks\\SupportedDatabase' => __DIR__ . '/..' . '/../lib/SetupChecks/SupportedDatabase.php',
108+
'OCA\\Settings\\SetupChecks\\SystemIs64bit' => __DIR__ . '/..' . '/../lib/SetupChecks/SystemIs64bit.php',
108109
'OCA\\Settings\\SetupChecks\\TransactionIsolation' => __DIR__ . '/..' . '/../lib/SetupChecks/TransactionIsolation.php',
109110
'OCA\\Settings\\UserMigration\\AccountMigrator' => __DIR__ . '/..' . '/../lib/UserMigration/AccountMigrator.php',
110111
'OCA\\Settings\\UserMigration\\AccountMigratorException' => __DIR__ . '/..' . '/../lib/UserMigration/AccountMigratorException.php',

apps/settings/lib/AppInfo/Application.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
use OCA\Settings\SetupChecks\RandomnessSecure;
6666
use OCA\Settings\SetupChecks\ReadOnlyConfig;
6767
use OCA\Settings\SetupChecks\SupportedDatabase;
68+
use OCA\Settings\SetupChecks\SystemIs64bit;
6869
use OCA\Settings\SetupChecks\TransactionIsolation;
6970
use OCA\Settings\UserMigration\AccountMigrator;
7071
use OCA\Settings\WellKnown\ChangePasswordHandler;
@@ -172,6 +173,7 @@ public function register(IRegistrationContext $context): void {
172173
$context->registerSetupCheck(RandomnessSecure::class);
173174
$context->registerSetupCheck(ReadOnlyConfig::class);
174175
$context->registerSetupCheck(SupportedDatabase::class);
176+
$context->registerSetupCheck(SystemIs64bit::class);
175177
$context->registerSetupCheck(TransactionIsolation::class);
176178

177179
$context->registerUserMigrator(AccountMigrator::class);

apps/settings/lib/Controller/CheckSetupController.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -632,14 +632,6 @@ protected function areWebauthnExtensionsEnabled(): bool {
632632
return true;
633633
}
634634

635-
protected function is64bit(): bool {
636-
if (PHP_INT_SIZE < 8) {
637-
return false;
638-
} else {
639-
return true;
640-
}
641-
}
642-
643635
protected function isMysqlUsedWithoutUTF8MB4(): bool {
644636
return ($this->config->getSystemValue('dbtype', 'sqlite') === 'mysql') && ($this->config->getSystemValue('mysql.utf8mb4', false) === false);
645637
}
@@ -755,7 +747,6 @@ public function check() {
755747
'appDirsWithDifferentOwner' => $this->getAppDirsWithDifferentOwner(),
756748
'isImagickEnabled' => $this->isImagickEnabled(),
757749
'areWebauthnExtensionsEnabled' => $this->areWebauthnExtensionsEnabled(),
758-
'is64bit' => $this->is64bit(),
759750
'pendingBigIntConversionColumns' => $this->hasBigIntConversionPendingColumns(),
760751
'isMysqlUsedWithoutUTF8MB4' => $this->isMysqlUsedWithoutUTF8MB4(),
761752
'isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed' => $this->isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed(),
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* @copyright Copyright (c) 2023 Côme Chilliet <come.chilliet@nextcloud.com>
7+
*
8+
* @author Côme Chilliet <come.chilliet@nextcloud.com>
9+
*
10+
* @license GNU AGPL version 3 or any later version
11+
*
12+
* This program is free software: you can redistribute it and/or modify
13+
* it under the terms of the GNU Affero General Public License as
14+
* published by the Free Software Foundation, either version 3 of the
15+
* License, or (at your option) any later version.
16+
*
17+
* This program is distributed in the hope that it will be useful,
18+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
19+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20+
* GNU Affero General Public License for more details.
21+
*
22+
* You should have received a copy of the GNU Affero General Public License
23+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
24+
*
25+
*/
26+
27+
namespace OCA\Settings\SetupChecks;
28+
29+
use OCP\IL10N;
30+
use OCP\IURLGenerator;
31+
use OCP\SetupCheck\ISetupCheck;
32+
use OCP\SetupCheck\SetupResult;
33+
34+
class SystemIs64bit implements ISetupCheck {
35+
public function __construct(
36+
private IL10N $l10n,
37+
private IURLGenerator $urlGenerator,
38+
) {
39+
}
40+
41+
public function getName(): string {
42+
return $this->l10n->t('Architecture');
43+
}
44+
45+
public function getCategory(): string {
46+
return 'system';
47+
}
48+
49+
protected function is64bit(): bool {
50+
if (PHP_INT_SIZE < 8) {
51+
return false;
52+
} else {
53+
return true;
54+
}
55+
}
56+
57+
public function run(): SetupResult {
58+
if ($this->is64bit()) {
59+
return SetupResult::success($this->l10n->t('64-bit'));
60+
} else {
61+
return SetupResult::warning(
62+
$this->l10n->t('It seems like you are running a 32-bit PHP version. Nextcloud needs 64-bit to run well. Please upgrade your OS and PHP to 64-bit!'),
63+
$this->urlGenerator->linkToDocs('admin-system-requirements')
64+
);
65+
}
66+
}
67+
}

apps/settings/tests/Controller/CheckSetupControllerTest.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,6 @@ protected function setUp(): void {
201201
'getAppDirsWithDifferentOwner',
202202
'isImagickEnabled',
203203
'areWebauthnExtensionsEnabled',
204-
'is64bit',
205204
'hasBigIntConversionPendingColumns',
206205
'isMysqlUsedWithoutUTF8MB4',
207206
'isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed',
@@ -376,11 +375,6 @@ public function testCheck() {
376375
->method('areWebauthnExtensionsEnabled')
377376
->willReturn(false);
378377

379-
$this->checkSetupController
380-
->expects($this->once())
381-
->method('is64bit')
382-
->willReturn(false);
383-
384378
$this->checkSetupController
385379
->expects($this->once())
386380
->method('hasBigIntConversionPendingColumns')
@@ -454,7 +448,6 @@ public function testCheck() {
454448
'appDirsWithDifferentOwner' => [],
455449
'isImagickEnabled' => false,
456450
'areWebauthnExtensionsEnabled' => false,
457-
'is64bit' => false,
458451
'pendingBigIntConversionColumns' => [],
459452
'isMysqlUsedWithoutUTF8MB4' => false,
460453
'isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed' => true,

core/js/setupchecks.js

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -318,17 +318,6 @@
318318
type: OC.SetupChecks.MESSAGE_TYPE_INFO
319319
})
320320
}
321-
if (!data.is64bit) {
322-
messages.push({
323-
msg: t(
324-
'core',
325-
'It seems like you are running a 32-bit PHP version. Nextcloud needs 64-bit to run well. Please upgrade your OS and PHP to 64-bit! For further details read {linkstart}the documentation page ↗{linkend} about this.'
326-
.replace('{linkstart}', '<a target="_blank" rel="noreferrer noopener" class="external" href="' + OC.theme.docPlaceholderUrl.replace('PLACEHOLDER', 'admin-system-requirements') + '">')
327-
.replace('{linkend}', '</a>'),
328-
),
329-
type: OC.SetupChecks.MESSAGE_TYPE_WARNING
330-
})
331-
}
332321
if (data.imageMagickLacksSVGSupport) {
333322
messages.push({
334323
msg: t('core', 'Module php-imagick in this instance has no SVG support. For better compatibility it is recommended to install it.'),

core/js/tests/specs/setupchecksSpec.js

Lines changed: 0 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,6 @@ describe('OC.SetupChecks tests', function() {
240240
appDirsWithDifferentOwner: [],
241241
isImagickEnabled: true,
242242
areWebauthnExtensionsEnabled: true,
243-
is64bit: true,
244243
pendingBigIntConversionColumns: [],
245244
isMysqlUsedWithoutUTF8MB4: false,
246245
isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,
@@ -299,7 +298,6 @@ describe('OC.SetupChecks tests', function() {
299298
appDirsWithDifferentOwner: [],
300299
isImagickEnabled: true,
301300
areWebauthnExtensionsEnabled: true,
302-
is64bit: true,
303301
pendingBigIntConversionColumns: [],
304302
isMysqlUsedWithoutUTF8MB4: false,
305303
isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,
@@ -358,7 +356,6 @@ describe('OC.SetupChecks tests', function() {
358356
appDirsWithDifferentOwner: [],
359357
isImagickEnabled: true,
360358
areWebauthnExtensionsEnabled: true,
361-
is64bit: true,
362359
pendingBigIntConversionColumns: [],
363360
isMysqlUsedWithoutUTF8MB4: false,
364361
isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,
@@ -413,7 +410,6 @@ describe('OC.SetupChecks tests', function() {
413410
appDirsWithDifferentOwner: [],
414411
isImagickEnabled: true,
415412
areWebauthnExtensionsEnabled: true,
416-
is64bit: true,
417413
pendingBigIntConversionColumns: [],
418414
isMysqlUsedWithoutUTF8MB4: false,
419415
isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,
@@ -468,7 +464,6 @@ describe('OC.SetupChecks tests', function() {
468464
],
469465
isImagickEnabled: true,
470466
areWebauthnExtensionsEnabled: true,
471-
is64bit: true,
472467
pendingBigIntConversionColumns: [],
473468
isMysqlUsedWithoutUTF8MB4: false,
474469
isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,
@@ -522,7 +517,6 @@ describe('OC.SetupChecks tests', function() {
522517
appDirsWithDifferentOwner: [],
523518
isImagickEnabled: true,
524519
areWebauthnExtensionsEnabled: true,
525-
is64bit: true,
526520
pendingBigIntConversionColumns: [],
527521
isMysqlUsedWithoutUTF8MB4: false,
528522
isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,
@@ -578,7 +572,6 @@ describe('OC.SetupChecks tests', function() {
578572
appDirsWithDifferentOwner: [],
579573
isImagickEnabled: true,
580574
areWebauthnExtensionsEnabled: true,
581-
is64bit: true,
582575
pendingBigIntConversionColumns: [],
583576
isMysqlUsedWithoutUTF8MB4: false,
584577
isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,
@@ -632,7 +625,6 @@ describe('OC.SetupChecks tests', function() {
632625
appDirsWithDifferentOwner: [],
633626
isImagickEnabled: true,
634627
areWebauthnExtensionsEnabled: true,
635-
is64bit: true,
636628
pendingBigIntConversionColumns: [],
637629
isMysqlUsedWithoutUTF8MB4: false,
638630
isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,
@@ -686,7 +678,6 @@ describe('OC.SetupChecks tests', function() {
686678
appDirsWithDifferentOwner: [],
687679
isImagickEnabled: true,
688680
areWebauthnExtensionsEnabled: true,
689-
is64bit: true,
690681
pendingBigIntConversionColumns: [],
691682
isMysqlUsedWithoutUTF8MB4: false,
692683
isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,
@@ -759,7 +750,6 @@ describe('OC.SetupChecks tests', function() {
759750
appDirsWithDifferentOwner: [],
760751
isImagickEnabled: true,
761752
areWebauthnExtensionsEnabled: true,
762-
is64bit: true,
763753
pendingBigIntConversionColumns: [],
764754
isMysqlUsedWithoutUTF8MB4: false,
765755
isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,
@@ -819,7 +809,6 @@ describe('OC.SetupChecks tests', function() {
819809
appDirsWithDifferentOwner: [],
820810
isImagickEnabled: true,
821811
areWebauthnExtensionsEnabled: true,
822-
is64bit: true,
823812
pendingBigIntConversionColumns: [],
824813
isMysqlUsedWithoutUTF8MB4: false,
825814
isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,
@@ -872,7 +861,6 @@ describe('OC.SetupChecks tests', function() {
872861
appDirsWithDifferentOwner: [],
873862
isImagickEnabled: true,
874863
areWebauthnExtensionsEnabled: true,
875-
is64bit: true,
876864
pendingBigIntConversionColumns: [],
877865
isMysqlUsedWithoutUTF8MB4: true,
878866
isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,
@@ -929,7 +917,6 @@ describe('OC.SetupChecks tests', function() {
929917
appDirsWithDifferentOwner: [],
930918
isImagickEnabled: true,
931919
areWebauthnExtensionsEnabled: true,
932-
is64bit: true,
933920
pendingBigIntConversionColumns: [],
934921
isMysqlUsedWithoutUTF8MB4: false,
935922
isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,
@@ -983,7 +970,6 @@ describe('OC.SetupChecks tests', function() {
983970
appDirsWithDifferentOwner: [],
984971
isImagickEnabled: true,
985972
areWebauthnExtensionsEnabled: true,
986-
is64bit: true,
987973
pendingBigIntConversionColumns: [],
988974
isMysqlUsedWithoutUTF8MB4: false,
989975
isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,
@@ -1034,7 +1020,6 @@ describe('OC.SetupChecks tests', function() {
10341020
appDirsWithDifferentOwner: [],
10351021
isImagickEnabled: true,
10361022
areWebauthnExtensionsEnabled: true,
1037-
is64bit: true,
10381023
pendingBigIntConversionColumns: [],
10391024
isMysqlUsedWithoutUTF8MB4: false,
10401025
isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: false,
@@ -1088,7 +1073,6 @@ describe('OC.SetupChecks tests', function() {
10881073
appDirsWithDifferentOwner: [],
10891074
isImagickEnabled: false,
10901075
areWebauthnExtensionsEnabled: true,
1091-
is64bit: true,
10921076
pendingBigIntConversionColumns: [],
10931077
isMysqlUsedWithoutUTF8MB4: false,
10941078
isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,
@@ -1142,7 +1126,6 @@ describe('OC.SetupChecks tests', function() {
11421126
appDirsWithDifferentOwner: [],
11431127
isImagickEnabled: true,
11441128
areWebauthnExtensionsEnabled: false,
1145-
is64bit: true,
11461129
pendingBigIntConversionColumns: [],
11471130
isMysqlUsedWithoutUTF8MB4: false,
11481131
isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,
@@ -1169,59 +1152,6 @@ describe('OC.SetupChecks tests', function() {
11691152
});
11701153
});
11711154

1172-
it('should return an error for 32bit instances', function(done) {
1173-
var async = OC.SetupChecks.checkSetup();
1174-
1175-
suite.server.requests[0].respond(
1176-
200,
1177-
{
1178-
'Content-Type': 'application/json',
1179-
},
1180-
JSON.stringify({
1181-
suggestedOverwriteCliURL: '',
1182-
isFairUseOfFreePushService: true,
1183-
forwardedForHeadersWorking: true,
1184-
isCorrectMemcachedPHPModuleInstalled: true,
1185-
OpcacheSetupRecommendations: [],
1186-
isSettimelimitAvailable: true,
1187-
missingIndexes: [],
1188-
missingPrimaryKeys: [],
1189-
missingColumns: [],
1190-
cronErrors: [],
1191-
cronInfo: {
1192-
diffInSeconds: 0
1193-
},
1194-
isMemoryLimitSufficient: true,
1195-
appDirsWithDifferentOwner: [],
1196-
isImagickEnabled: true,
1197-
areWebauthnExtensionsEnabled: true,
1198-
is64bit: false,
1199-
pendingBigIntConversionColumns: [],
1200-
isMysqlUsedWithoutUTF8MB4: false,
1201-
isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,
1202-
reverseProxyGeneratedURL: 'https://server',
1203-
temporaryDirectoryWritable: true,
1204-
generic: {
1205-
network: {
1206-
"Internet connectivity": {
1207-
severity: "success",
1208-
description: null,
1209-
linkToDoc: null
1210-
}
1211-
},
1212-
},
1213-
})
1214-
);
1215-
1216-
async.done(function( data, s, x ){
1217-
expect(data).toEqual([{
1218-
msg: 'It seems like you are running a 32-bit PHP version. Nextcloud needs 64-bit to run well. Please upgrade your OS and PHP to 64-bit! For further details read <a href="https://docs.example.org/admin-system-requirements" class="external" rel="noreferrer noopener">the documentation page ↗</a> about this.',
1219-
type: OC.SetupChecks.MESSAGE_TYPE_WARNING
1220-
}]);
1221-
done();
1222-
});
1223-
});
1224-
12251155
it('should return an info if there is no default phone region', function(done) {
12261156
var async = OC.SetupChecks.checkSetup();
12271157

@@ -1248,7 +1178,6 @@ describe('OC.SetupChecks tests', function() {
12481178
appDirsWithDifferentOwner: [],
12491179
isImagickEnabled: true,
12501180
areWebauthnExtensionsEnabled: true,
1251-
is64bit: true,
12521181
pendingBigIntConversionColumns: [],
12531182
isMysqlUsedWithoutUTF8MB4: false,
12541183
isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,
@@ -1308,7 +1237,6 @@ describe('OC.SetupChecks tests', function() {
13081237
appDirsWithDifferentOwner: [],
13091238
isImagickEnabled: true,
13101239
areWebauthnExtensionsEnabled: true,
1311-
is64bit: true,
13121240
pendingBigIntConversionColumns: [],
13131241
isMysqlUsedWithoutUTF8MB4: false,
13141242
isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,

0 commit comments

Comments
 (0)