-
-
Notifications
You must be signed in to change notification settings - Fork 5k
Expand file tree
/
Copy pathServerIdConfig.php
More file actions
63 lines (52 loc) · 1.72 KB
/
Copy pathServerIdConfig.php
File metadata and controls
63 lines (52 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\Settings\SetupChecks;
use OCP\IConfig;
use OCP\IL10N;
use OCP\IURLGenerator;
use OCP\SetupCheck\ISetupCheck;
use OCP\SetupCheck\SetupResult;
use Override;
final class ServerIdConfig implements ISetupCheck {
public function __construct(
private readonly IL10N $l10n,
private readonly IConfig $config,
private readonly IURLGenerator $urlGenerator,
) {
}
#[Override]
public function getName(): string {
return $this->l10n->t('Configuration server ID');
}
#[Override]
public function getCategory(): string {
return 'config';
}
#[Override]
public function run(): SetupResult {
$serverid = $this->config->getSystemValueInt('serverid', PHP_INT_MIN);
$linkToDoc = $this->urlGenerator->linkToDocs('admin-update');
if ($serverid === PHP_INT_MIN) {
return SetupResult::info(
$this->l10n->t(
'The ``serverid`` parameter is not configured. '
. 'By default, Nextcloud uses a fallback based on the server hostname. '
. 'The fallback is safe for a standalone setup.'
. 'However, if you are running Nextcloud on multiple servers, you plan to expand your setup in the future, or simply want to suppress this message, you should explicitly set a unique integer ``serverid`` (0–1023) for each server. '
),
$linkToDoc,
);
}
if ($serverid < 0 || $serverid > 511) {
return SetupResult::error(
$this->l10n->t('"%d" is not a valid server identifier. It must be between 0 and 511.', [$serverid]),
$linkToDoc,
);
}
return SetupResult::success($this->l10n->t('Server identifier is configured and valid.'));
}
}