]> source.dussan.org Git - nextcloud-server.git/commitdiff
Migrate debug mode check to new SetupCheck API 42942/head
authorCôme Chilliet <come.chilliet@nextcloud.com>
Thu, 18 Jan 2024 15:09:11 +0000 (16:09 +0100)
committerCôme Chilliet <91878298+come-nc@users.noreply.github.com>
Mon, 29 Jan 2024 09:11:03 +0000 (10:11 +0100)
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
apps/settings/composer/composer/autoload_classmap.php
apps/settings/composer/composer/autoload_static.php
apps/settings/lib/AppInfo/Application.php
apps/settings/lib/SetupChecks/DebugMode.php [new file with mode: 0644]
core/js/setupchecks.js

index 0d8e177c1fde25416da4b352e796e734c197854b..ef81604ca0e9f2e7cb1dffd4971236ed33c076f6 100644 (file)
@@ -86,6 +86,7 @@ return array(
     'OCA\\Settings\\SetupChecks\\DatabaseHasMissingIndices' => $baseDir . '/../lib/SetupChecks/DatabaseHasMissingIndices.php',
     'OCA\\Settings\\SetupChecks\\DatabaseHasMissingPrimaryKeys' => $baseDir . '/../lib/SetupChecks/DatabaseHasMissingPrimaryKeys.php',
     'OCA\\Settings\\SetupChecks\\DatabasePendingBigIntConversions' => $baseDir . '/../lib/SetupChecks/DatabasePendingBigIntConversions.php',
+    'OCA\\Settings\\SetupChecks\\DebugMode' => $baseDir . '/../lib/SetupChecks/DebugMode.php',
     'OCA\\Settings\\SetupChecks\\DefaultPhoneRegionSet' => $baseDir . '/../lib/SetupChecks/DefaultPhoneRegionSet.php',
     'OCA\\Settings\\SetupChecks\\EmailTestSuccessful' => $baseDir . '/../lib/SetupChecks/EmailTestSuccessful.php',
     'OCA\\Settings\\SetupChecks\\FileLocking' => $baseDir . '/../lib/SetupChecks/FileLocking.php',
index 1b95d35a9063fd563bf4661be8e3b871e5359b16..fe23224d21493f11de7d0cbbd33c6a3133580f99 100644 (file)
@@ -101,6 +101,7 @@ class ComposerStaticInitSettings
         'OCA\\Settings\\SetupChecks\\DatabaseHasMissingIndices' => __DIR__ . '/..' . '/../lib/SetupChecks/DatabaseHasMissingIndices.php',
         'OCA\\Settings\\SetupChecks\\DatabaseHasMissingPrimaryKeys' => __DIR__ . '/..' . '/../lib/SetupChecks/DatabaseHasMissingPrimaryKeys.php',
         'OCA\\Settings\\SetupChecks\\DatabasePendingBigIntConversions' => __DIR__ . '/..' . '/../lib/SetupChecks/DatabasePendingBigIntConversions.php',
+        'OCA\\Settings\\SetupChecks\\DebugMode' => __DIR__ . '/..' . '/../lib/SetupChecks/DebugMode.php',
         'OCA\\Settings\\SetupChecks\\DefaultPhoneRegionSet' => __DIR__ . '/..' . '/../lib/SetupChecks/DefaultPhoneRegionSet.php',
         'OCA\\Settings\\SetupChecks\\EmailTestSuccessful' => __DIR__ . '/..' . '/../lib/SetupChecks/EmailTestSuccessful.php',
         'OCA\\Settings\\SetupChecks\\FileLocking' => __DIR__ . '/..' . '/../lib/SetupChecks/FileLocking.php',
index 35e5009f1e8722f29ba2b6fc9c595cfe37482a34..8318391a2e6723ff53211e26de6f8bb09cbd3061 100644 (file)
@@ -58,6 +58,7 @@ use OCA\Settings\SetupChecks\DatabaseHasMissingColumns;
 use OCA\Settings\SetupChecks\DatabaseHasMissingIndices;
 use OCA\Settings\SetupChecks\DatabaseHasMissingPrimaryKeys;
 use OCA\Settings\SetupChecks\DatabasePendingBigIntConversions;
+use OCA\Settings\SetupChecks\DebugMode;
 use OCA\Settings\SetupChecks\DefaultPhoneRegionSet;
 use OCA\Settings\SetupChecks\EmailTestSuccessful;
 use OCA\Settings\SetupChecks\FileLocking;
@@ -184,6 +185,7 @@ class Application extends App implements IBootstrap {
                $context->registerSetupCheck(DatabaseHasMissingIndices::class);
                $context->registerSetupCheck(DatabaseHasMissingPrimaryKeys::class);
                $context->registerSetupCheck(DatabasePendingBigIntConversions::class);
+               $context->registerSetupCheck(DebugMode::class);
                $context->registerSetupCheck(DefaultPhoneRegionSet::class);
                $context->registerSetupCheck(EmailTestSuccessful::class);
                $context->registerSetupCheck(FileLocking::class);
diff --git a/apps/settings/lib/SetupChecks/DebugMode.php b/apps/settings/lib/SetupChecks/DebugMode.php
new file mode 100644 (file)
index 0000000..83b52d6
--- /dev/null
@@ -0,0 +1,55 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * @copyright Copyright (c) 2023 Côme Chilliet <come.chilliet@nextcloud.com>
+ *
+ * @author Côme Chilliet <come.chilliet@nextcloud.com>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+namespace OCA\Settings\SetupChecks;
+
+use OCP\IConfig;
+use OCP\IL10N;
+use OCP\SetupCheck\ISetupCheck;
+use OCP\SetupCheck\SetupResult;
+
+class DebugMode implements ISetupCheck {
+       public function __construct(
+               private IL10N $l10n,
+               private IConfig $config,
+       ) {
+       }
+
+       public function getName(): string {
+               return $this->l10n->t('Debug mode');
+       }
+
+       public function getCategory(): string {
+               return 'system';
+       }
+
+       public function run(): SetupResult {
+               if ($this->config->getSystemValueBool('debug', false)) {
+                       return SetupResult::warning($this->l10n->t('This instance is running in debug mode. Only enable this for local development and not in production environments.'));
+               } else {
+                       return SetupResult::success($this->l10n->t('Debug mode is disabled.'));
+               }
+       }
+}
index 7400d02d30d38dee8a8d1bb3e3c4558913c5c3c6..fe6ab1105a2f9718550ef9ea1c4b699487c16e8e 100644 (file)
                                                        type: OC.SetupChecks.MESSAGE_TYPE_WARNING
                                                })
                                        }
-                                       if (window.oc_debug) {
-                                               messages.push({
-                                                       msg: t('core', 'This instance is running in debug mode. Only enable this for local development and not in production environments.'),
-                                                       type: OC.SetupChecks.MESSAGE_TYPE_WARNING
-                                               })
-                                       }
                                        if (Object.keys(data.generic).length > 0) {
                                                Object.keys(data.generic).forEach(function(key){
                                                        Object.keys(data.generic[key]).forEach(function(title){