diff --git a/core/drupalci.yml b/core/drupalci.yml index 63df934307..a5bb64d1e3 100644 --- a/core/drupalci.yml +++ b/core/drupalci.yml @@ -19,40 +19,8 @@ build: # halt-on-fail can be set on the run_tests tasks in order to fail fast. # suppress-deprecations is false in order to be alerted to usages of # deprecated code. - run_tests.phpunit: - types: 'PHPUnit-Unit' - testgroups: '--all' - suppress-deprecations: false - halt-on-fail: false - run_tests.kernel: - types: 'PHPUnit-Kernel' - testgroups: '--all' - suppress-deprecations: false - halt-on-fail: false - run_tests.build: - # Limit concurrency due to disk space concerns. - concurrency: 15 - types: 'PHPUnit-Build' - testgroups: '--all' - suppress-deprecations: false - halt-on-fail: false run_tests.functional: types: 'PHPUnit-Functional' - testgroups: '--all' - suppress-deprecations: false - halt-on-fail: false - run_tests.javascript: - concurrency: 15 - types: 'PHPUnit-FunctionalJavascript' - testgroups: '--all' + testgroups: '--class "Drupal\Tests\system\Functional\Update\DatabaseVersionCheckUpdateTest"' suppress-deprecations: false halt-on-fail: false - # Run nightwatch testing. - # @see https://www.drupal.org/project/drupal/issues/2869825 - nightwatchjs: - # Re-run Composer plugin tests after installing Composer 2 - container_command.composer-upgrade: - commands: - - "sudo composer self-update --snapshot" - - "./vendor/bin/phpunit -c core --group VendorHardening,ProjectMessage,Scaffold" - halt-on-fail: true diff --git a/core/lib/Drupal/Core/Database/Install/Tasks.php b/core/lib/Drupal/Core/Database/Install/Tasks.php index 47b973b9b0..b7fceace11 100644 --- a/core/lib/Drupal/Core/Database/Install/Tasks.php +++ b/core/lib/Drupal/Core/Database/Install/Tasks.php @@ -151,6 +151,19 @@ public function runTasks() { return $this->results['fail']; } + /** + * Checks engine version requirements for the status report. + * + * This method is called during runtime and update requirements checks. + * + * @return \Drupal\Core\StringTranslation\TranslatableMarkup[] + * A list of error messages. + */ + final public function engineVersionRequirementsCheck() { + $this->checkEngineVersion(); + return $this->results['fail']; + } + /** * Check if we can connect to the database. */ diff --git a/core/modules/system/system.install b/core/modules/system/system.install index 89335d0136..dfe23290d6 100644 --- a/core/modules/system/system.install +++ b/core/modules/system/system.install @@ -427,9 +427,11 @@ function system_requirements($phase) { $requirements['database_extensions']['value'] = t('Enabled'); } } - else { + + if ($phase === 'runtime' || $phase === 'update') { // Database information. $class = Database::getConnection()->getDriverClass('Install\\Tasks'); + /** @var \Drupal\Core\Database\Install\Tasks $tasks */ $tasks = new $class(); $requirements['database_system'] = [ 'title' => t('Database system'), @@ -439,6 +441,19 @@ function system_requirements($phase) { 'title' => t('Database system version'), 'value' => Database::getConnection()->version(), ]; + + $errors = $tasks->engineVersionRequirementsCheck(); + $error_count = count($errors); + if ($error_count > 0) { + $error_message = [ + '#theme' => 'item_list', + '#items' => $errors, + // Use the comma-list style to display a single error without bullets. + '#context' => ['list_style' => $error_count == 1 ? 'comma-list' : ''], + ]; + $requirements['database_system_version']['severity'] = REQUIREMENT_ERROR; + $requirements['database_system_version']['description'] = $error_message; + } } // Test PHP memory_limit diff --git a/core/modules/system/tests/modules/driver_test/src/Driver/Database/DrivertestMysqlDeprecatedVersion/Connection.php b/core/modules/system/tests/modules/driver_test/src/Driver/Database/DrivertestMysqlDeprecatedVersion/Connection.php new file mode 100644 index 0000000000..c7ec0fed72 --- /dev/null +++ b/core/modules/system/tests/modules/driver_test/src/Driver/Database/DrivertestMysqlDeprecatedVersion/Connection.php @@ -0,0 +1,49 @@ +databaseVersion; + } + + /** + * {@inheritdoc} + */ + protected function getServerVersion(): string { + return $this->databaseVersion; + } + +} diff --git a/core/modules/system/tests/modules/driver_test/src/Driver/Database/DrivertestMysqlDeprecatedVersion/Insert.php b/core/modules/system/tests/modules/driver_test/src/Driver/Database/DrivertestMysqlDeprecatedVersion/Insert.php new file mode 100644 index 0000000000..86affc1a34 --- /dev/null +++ b/core/modules/system/tests/modules/driver_test/src/Driver/Database/DrivertestMysqlDeprecatedVersion/Insert.php @@ -0,0 +1,10 @@ +ensureUpdatesToRun(); + } + + /** + * Tests that updates fail if the database does not meet the minimum version. + */ + public function testUpdate() { + if (Database::getConnection()->driver() !== 'mysql') { + $this->markTestSkipped('This test only works with the mysql driver'); + } + + // Use a database driver that reports a fake database version that does + // not meet requirements. + $connection = Database::getConnectionInfo()['default']; + unset($connection['init_commands'], $connection['pdo'], $connection['prefix']); + $connection['driver'] = 'DrivertestMysqlDeprecatedVersion'; + $connection['namespace'] = 'Drupal\driver_test\Driver\Database\DrivertestMysqlDeprecatedVersion'; + $connection['autoload'] = Database::findDriverAutoloadDirectory($connection['namespace'], \Drupal::root()); + + $settings['databases']['default']['default'] = (object) [ + 'value' => $connection, + 'required' => TRUE, + ]; + $settings['settings'] = [ + 'update_free_access' => (object) [ + 'value' => TRUE, + 'required' => TRUE, + ], + ]; + $this->writeSettings($settings); + + $this->drupalGet(Url::fromRoute('system.db_update')); + $this->assertSession()->pageTextContains('Errors found'); + $this->assertSession()->pageTextContains('The database server version 10.2.31-MariaDB-1:10.2.31+maria~bionic-log is less than the minimum required version'); + } + +}