]> source.dussan.org Git - nextcloud-server.git/commitdiff
Merge SQlite warning to existing SupportedDatabase setup check 41535/head
authorCôme Chilliet <come.chilliet@nextcloud.com>
Thu, 16 Nov 2023 10:48:04 +0000 (11:48 +0100)
committerCôme Chilliet <91878298+come-nc@users.noreply.github.com>
Thu, 7 Dec 2023 14:45:27 +0000 (15:45 +0100)
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
apps/settings/lib/Controller/CheckSetupController.php
apps/settings/lib/SetupChecks/SupportedDatabase.php
apps/settings/tests/Controller/CheckSetupControllerTest.php
apps/settings/tests/SetupChecks/SupportedDatabaseTest.php
core/js/setupchecks.js

index 07ab12426bb0dc4afc0d5b2e79a4675699108824..14f7068ce59a1fb6d3f761a90ef9d78e46182ecb 100644 (file)
@@ -401,10 +401,6 @@ Raw output
                return $recommendations;
        }
 
-       protected function isSqliteUsed() {
-               return str_contains($this->config->getSystemValue('dbtype'), 'sqlite');
-       }
-
        protected function getSuggestedOverwriteCliURL(): string {
                $currentOverwriteCliUrl = $this->config->getSystemValue('overwrite.cli.url', '');
                $suggestedOverwriteCliUrl = $this->request->getServerProtocol() . '://' . $this->request->getInsecureServerHost() . \OC::$WEBROOT;
@@ -574,8 +570,6 @@ Raw output
                                'codeIntegrityCheckerDocumentation' => $this->urlGenerator->linkToDocs('admin-code-integrity'),
                                'OpcacheSetupRecommendations' => $this->getOpcacheSetupRecommendations(),
                                'isSettimelimitAvailable' => $this->isSettimelimitAvailable(),
-                               'isSqliteUsed' => $this->isSqliteUsed(),
-                               'databaseConversionDocumentation' => $this->urlGenerator->linkToDocs('admin-db-conversion'),
                                'appDirsWithDifferentOwner' => $this->getAppDirsWithDifferentOwner(),
                                'isImagickEnabled' => $this->isImagickEnabled(),
                                'areWebauthnExtensionsEnabled' => $this->areWebauthnExtensionsEnabled(),
index 7cb4820952fc0d6214ad6c3acf4b543fb1d3ac34..5739bc17958f5f2e3d938bd3c16dd2fb3cbbac89 100644 (file)
@@ -33,12 +33,14 @@ use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
 use Doctrine\DBAL\Platforms\SqlitePlatform;
 use OCP\IDBConnection;
 use OCP\IL10N;
+use OCP\IURLGenerator;
 use OCP\SetupCheck\ISetupCheck;
 use OCP\SetupCheck\SetupResult;
 
 class SupportedDatabase implements ISetupCheck {
        public function __construct(
                private IL10N $l10n,
+               private IURLGenerator $urlGenerator,
                private IDBConnection $connection,
        ) {
        }
@@ -81,7 +83,10 @@ class SupportedDatabase implements ISetupCheck {
                } elseif ($databasePlatform instanceof OraclePlatform) {
                        $version = 'Oracle';
                } elseif ($databasePlatform instanceof SqlitePlatform) {
-                       $version = 'Sqlite';
+                       return SetupResult::warning(
+                               $this->l10n->t('SQLite is currently being used as the backend database. For larger installations we recommend that you switch to a different database backend. This is particularly recommended when using the desktop client for file synchronisation. To migrate to another database use the command line tool: "occ db:convert-type".'),
+                               $this->urlGenerator->linkToDocs('admin-db-conversion')
+                       );
                } else {
                        return SetupResult::error($this->l10n->t('Unknown database platform'));
                }
index bd3ed270cdd686249ef274a4b7fc4689ab6a1852..a4cd6bb0a961eb85c2e67dc596596644ed722253 100644 (file)
@@ -165,7 +165,6 @@ class CheckSetupControllerTest extends TestCase {
                                'getCurlVersion',
                                'isPhpOutdated',
                                'getOpcacheSetupRecommendations',
-                               'isSqliteUsed',
                                'isPHPMailerUsed',
                                'getAppDirsWithDifferentOwner',
                                'isImagickEnabled',
@@ -213,9 +212,6 @@ class CheckSetupControllerTest extends TestCase {
                        ->expects($this->once())
                        ->method('getOpcacheSetupRecommendations')
                        ->willReturn(['recommendation1', 'recommendation2']);
-               $this->checkSetupController
-                       ->method('isSqliteUsed')
-                       ->willReturn(false);
                $this->checkSetupController
                        ->expects($this->once())
                        ->method('getSuggestedOverwriteCliURL')
@@ -305,8 +301,6 @@ class CheckSetupControllerTest extends TestCase {
                                'codeIntegrityCheckerDocumentation' => 'http://docs.example.org/server/go.php?to=admin-code-integrity',
                                'OpcacheSetupRecommendations' => ['recommendation1', 'recommendation2'],
                                'isSettimelimitAvailable' => true,
-                               'isSqliteUsed' => false,
-                               'databaseConversionDocumentation' => 'http://docs.example.org/server/go.php?to=admin-db-conversion',
                                'appDirsWithDifferentOwner' => [],
                                'isImagickEnabled' => false,
                                'areWebauthnExtensionsEnabled' => false,
index 5521bec34b56a3663f58484feb9f63883e5cb6fd..aede25475c5f922ff4d099ac9c03c30fa6eb3c37 100644 (file)
@@ -25,8 +25,11 @@ declare(strict_types=1);
  */
 namespace OCA\Settings\Tests;
 
+use Doctrine\DBAL\Platforms\SqlitePlatform;
 use OCA\Settings\SetupChecks\SupportedDatabase;
+use OCP\IDBConnection;
 use OCP\IL10N;
+use OCP\IUrlGenerator;
 use OCP\SetupCheck\SetupResult;
 use Test\TestCase;
 
@@ -34,9 +37,33 @@ use Test\TestCase;
  * @group DB
  */
 class SupportedDatabaseTest extends TestCase {
+       private IL10N $l10n;
+       private IUrlGenerator $urlGenerator;
+       private IDBConnection $connection;
+
+       private SupportedDatabase $check;
+
+       protected function setUp(): void {
+               parent::setUp();
+
+               $this->l10n = $this->getMockBuilder(IL10N::class)->getMock();
+               $this->urlGenerator = $this->getMockBuilder(IUrlGenerator::class)->getMock();
+               $this->connection = \OCP\Server::get(IDBConnection::class);
+
+               $this->check = new SupportedDatabase(
+                       $this->l10n,
+                       $this->urlGenerator,
+                       \OCP\Server::get(IDBConnection::class)
+               );
+       }
+
        public function testPass(): void {
-               $l10n = $this->getMockBuilder(IL10N::class)->getMock();
-               $check = new SupportedDatabase($l10n, \OC::$server->getDatabaseConnection());
-               $this->assertEquals(SetupResult::SUCCESS, $check->run()->getSeverity());
+               $platform = $this->connection->getDatabasePlatform();
+               if ($platform instanceof SqlitePlatform) {
+                       /** SQlite always gets a warning */
+                       $this->assertEquals(SetupResult::WARNING, $this->check->run()->getSeverity());
+               } else {
+                       $this->assertEquals(SetupResult::SUCCESS, $this->check->run()->getSeverity());
+               }
        }
 }
index c947f3c30e74228bfe30b04cb7a9a886102184a5..e7ad920760eda938c8d8c310dbfe4d68d687d0c7 100644 (file)
                                                        type: OC.SetupChecks.MESSAGE_TYPE_INFO
                                                })
                                        }
-                                       if (data.isSqliteUsed) {
-                                               messages.push({
-                                                       msg: t('core', 'SQLite is currently being used as the backend database. For larger installations we recommend that you switch to a different database backend.') + ' ' + t('core', 'This is particularly recommended when using the desktop client for file synchronisation.') + ' ' +
-                                                       t('core', 'To migrate to another database use the command line tool: "occ db:convert-type", or see the {linkstart}documentation ↗{linkend}.')
-                                                               .replace('{linkstart}', '<a target="_blank" rel="noreferrer noopener" class="external" href="' + data.databaseConversionDocumentation + '">')
-                                                               .replace('{linkend}', '</a>'),
-                                                       type: OC.SetupChecks.MESSAGE_TYPE_WARNING
-                                               })
-                                       }
 
                                        if(data.appDirsWithDifferentOwner && data.appDirsWithDifferentOwner.length > 0) {
                                                var appDirsWithDifferentOwner = data.appDirsWithDifferentOwner.reduce(