Skip to content

Commit c907198

Browse files
committed
Migrate debug mode check to new SetupCheck API
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
1 parent d4c0d15 commit c907198

5 files changed

Lines changed: 59 additions & 6 deletions

File tree

apps/settings/composer/composer/autoload_classmap.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
'OCA\\Settings\\SetupChecks\\DatabaseHasMissingIndices' => $baseDir . '/../lib/SetupChecks/DatabaseHasMissingIndices.php',
8787
'OCA\\Settings\\SetupChecks\\DatabaseHasMissingPrimaryKeys' => $baseDir . '/../lib/SetupChecks/DatabaseHasMissingPrimaryKeys.php',
8888
'OCA\\Settings\\SetupChecks\\DatabasePendingBigIntConversions' => $baseDir . '/../lib/SetupChecks/DatabasePendingBigIntConversions.php',
89+
'OCA\\Settings\\SetupChecks\\DebugMode' => $baseDir . '/../lib/SetupChecks/DebugMode.php',
8990
'OCA\\Settings\\SetupChecks\\DefaultPhoneRegionSet' => $baseDir . '/../lib/SetupChecks/DefaultPhoneRegionSet.php',
9091
'OCA\\Settings\\SetupChecks\\EmailTestSuccessful' => $baseDir . '/../lib/SetupChecks/EmailTestSuccessful.php',
9192
'OCA\\Settings\\SetupChecks\\FileLocking' => $baseDir . '/../lib/SetupChecks/FileLocking.php',

apps/settings/composer/composer/autoload_static.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ class ComposerStaticInitSettings
101101
'OCA\\Settings\\SetupChecks\\DatabaseHasMissingIndices' => __DIR__ . '/..' . '/../lib/SetupChecks/DatabaseHasMissingIndices.php',
102102
'OCA\\Settings\\SetupChecks\\DatabaseHasMissingPrimaryKeys' => __DIR__ . '/..' . '/../lib/SetupChecks/DatabaseHasMissingPrimaryKeys.php',
103103
'OCA\\Settings\\SetupChecks\\DatabasePendingBigIntConversions' => __DIR__ . '/..' . '/../lib/SetupChecks/DatabasePendingBigIntConversions.php',
104+
'OCA\\Settings\\SetupChecks\\DebugMode' => __DIR__ . '/..' . '/../lib/SetupChecks/DebugMode.php',
104105
'OCA\\Settings\\SetupChecks\\DefaultPhoneRegionSet' => __DIR__ . '/..' . '/../lib/SetupChecks/DefaultPhoneRegionSet.php',
105106
'OCA\\Settings\\SetupChecks\\EmailTestSuccessful' => __DIR__ . '/..' . '/../lib/SetupChecks/EmailTestSuccessful.php',
106107
'OCA\\Settings\\SetupChecks\\FileLocking' => __DIR__ . '/..' . '/../lib/SetupChecks/FileLocking.php',

apps/settings/lib/AppInfo/Application.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
use OCA\Settings\SetupChecks\DatabaseHasMissingIndices;
5959
use OCA\Settings\SetupChecks\DatabaseHasMissingPrimaryKeys;
6060
use OCA\Settings\SetupChecks\DatabasePendingBigIntConversions;
61+
use OCA\Settings\SetupChecks\DebugMode;
6162
use OCA\Settings\SetupChecks\DefaultPhoneRegionSet;
6263
use OCA\Settings\SetupChecks\EmailTestSuccessful;
6364
use OCA\Settings\SetupChecks\FileLocking;
@@ -184,6 +185,7 @@ public function register(IRegistrationContext $context): void {
184185
$context->registerSetupCheck(DatabaseHasMissingIndices::class);
185186
$context->registerSetupCheck(DatabaseHasMissingPrimaryKeys::class);
186187
$context->registerSetupCheck(DatabasePendingBigIntConversions::class);
188+
$context->registerSetupCheck(DebugMode::class);
187189
$context->registerSetupCheck(DefaultPhoneRegionSet::class);
188190
$context->registerSetupCheck(EmailTestSuccessful::class);
189191
$context->registerSetupCheck(FileLocking::class);
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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+
namespace OCA\Settings\SetupChecks;
27+
28+
use OCP\IConfig;
29+
use OCP\IL10N;
30+
use OCP\SetupCheck\ISetupCheck;
31+
use OCP\SetupCheck\SetupResult;
32+
33+
class DebugMode implements ISetupCheck {
34+
public function __construct(
35+
private IL10N $l10n,
36+
private IConfig $config,
37+
) {
38+
}
39+
40+
public function getName(): string {
41+
return $this->l10n->t('Debug mode');
42+
}
43+
44+
public function getCategory(): string {
45+
return 'system';
46+
}
47+
48+
public function run(): SetupResult {
49+
if ($this->config->getSystemValueBool('debug', false)) {
50+
return SetupResult::warning($this->l10n->t('This instance is running in debug mode. Only enable this for local development and not in production environments.'));
51+
} else {
52+
return SetupResult::success($this->l10n->t('Debug mode is disabled.'));
53+
}
54+
}
55+
}

core/js/setupchecks.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -188,12 +188,6 @@
188188
type: OC.SetupChecks.MESSAGE_TYPE_WARNING
189189
})
190190
}
191-
if (window.oc_debug) {
192-
messages.push({
193-
msg: t('core', 'This instance is running in debug mode. Only enable this for local development and not in production environments.'),
194-
type: OC.SetupChecks.MESSAGE_TYPE_WARNING
195-
})
196-
}
197191
if (Object.keys(data.generic).length > 0) {
198192
Object.keys(data.generic).forEach(function(key){
199193
Object.keys(data.generic[key]).forEach(function(title){

0 commit comments

Comments
 (0)