Problem/Motivation

In #3192487: Warn about upcoming JSON database support requirement in Drupal 9 we added a requirements check. Here, we are making Drupal installation fail on Drupal 10 is JSON is not supported by the database.

Proposed resolution

Update the list of checked SQL commands.

Remaining tasks

TBD

User interface changes

None

API changes

None

Data model changes

None

Release notes snippet

TBD

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Gábor Hojtsy created an issue. See original summary.

Gábor Hojtsy’s picture

Status: Postponed » Needs review
FileSize
930 bytes

I think the simplest is to add it to the install checklist. We already have infrastructure to check these. Should also remove the code added in #3192487: Warn about upcoming JSON database support requirement in Drupal 9 then, since we don't need the custom solution there anymore. Should only be committed to the 10.x branch but will send for a test out of curiosity :D

Gábor Hojtsy’s picture

Status: Needs review » Postponed
daffie’s picture

murilohp’s picture

Hey, I made a new patch based on #3192487, I created a new function to test the json support and used the \Drupal\Core\Database\Connection::hasJson to handle different databases.

We could find a way to refactor it to show the query and the error in case if something goes wrong during the installation. What do you think?

murilohp’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 7: 3203193-6.patch, failed testing. View results

murilohp’s picture

Forgot to remove the tests from #3192487, this new patch should fix the fail tests.

murilohp’s picture

Status: Needs work » Needs review
daffie’s picture

+++ b/core/modules/system/system.install
@@ -487,22 +487,6 @@ function system_requirements($phase) {
-  if ($phase == 'runtime') {
-    // Test JSON support. To be required from Drupal 10.0.
-    // @todo remove in https://www.drupal.org/project/drupal/issues/3203193
-    $requirements['database_support_json'] = [
-      'title' => t('Database support for JSON'),
-      'severity' => REQUIREMENT_OK,
-      'value' => t('Available'),
-      'description' => t('Is required in Drupal 10.0.'),
-    ];
-
-    if (!Database::getConnection()->hasJson()) {
-      $requirements['database_support_json']['value'] = t('Not available');
-      $requirements['database_support_json']['severity'] = REQUIREMENT_WARNING;
-    }
-  }
-

We cannot remove this. It needs to change to a 'REQUIREMENT_ERROR' when there is no JSON support. The stuff in Install/Tasks is only for new sites. Existing sites also need to have JSON support.

The if-statement with $phase == 'runtime' can be removed. Existing sites need to have JSON support when they are in "install", "update" or in the "runtime" phase.

daffie’s picture

Component: sqlite db driver » database system
murilohp’s picture

Thanks for the review @daffie! I made this new patch addressing #11.

The if-statement with $phase == 'runtime' can be removed. Existing sites need to have JSON support when they are in "install", "update" or in the "runtime" phase.

I kept the if-statement on this new patch, validating the "runtime" and "update", the "install" phase, does not have a database connection(which would fail the tests and probably the installation), for this scenario, I tested installing a new site and the core/lib/Drupal/Core/Database/Install/Tasks.php::checkJsonSupport were able to validate the JSON support.

daffie’s picture

Status: Needs review » Reviewed & tested by the community

The code changes look good to me.
The problem is that we should add testing, only I do not see how.
The new method in Drupal\Core\Database\Install\Tasks must pass the functional installertest and therefor has testing.
The change in the file system.install has already have testing.
For me it is RTBC.

@murilohp: Thank you for working on this.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 13: 3203193-13.patch, failed testing. View results

murilohp’s picture

Status: Needs work » Reviewed & tested by the community

The failed tests were fixed, moving back RTBC

catch’s picture

Status: Reviewed & tested by the community » Needs work
  1. +++ b/core/lib/Drupal/Core/Database/Install/Tasks.php
    @@ -386,4 +390,16 @@ protected function getConnection() {
    +   */
    +  protected function checkJsonSupport() {
    +    if ($this->getConnection()->hasJson()) {
    +      $this->pass(t('Drupal can use JSON database commands.'));
    +    }
    +    else {
    +      $this->fail(t('Failed to use <strong>JSON_TYPE</strong>. We tried testing database for JSON support and the test is failing.'));
    +    }
    +  }
    +
    

    I think this should be something like:

    'Database connection supports the JSON type'.

    For the fail message, not sure entirely, but it should probably link to https://www.drupal.org/docs/system-requirements

  2. +++ b/core/lib/Drupal/Core/Database/Install/Tasks.php
    @@ -386,4 +390,16 @@ protected function getConnection() {
    +   */
    

    s/json/JSON/

ankithashetty’s picture

Updated patch as suggested in #17 , thanks!

Status: Needs review » Needs work

The last submitted patch, 18: 3203193-18.patch, failed testing. View results

daffie’s picture

Status: Needs work » Reviewed & tested by the community

Back to RTBC

catch’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/lib/Drupal/Core/Database/Install/Tasks.php
@@ -386,4 +390,16 @@ protected function getConnection() {
+    else {
+      $this->fail(t('<a href="https://www.drupal.org/docs/system-requirements">Failed to use <strong>JSON_TYPE</strong>. We tried testing database for JSON support and the test is failing.</a>'));
+    }

Sorry this still needs to be more neutral I think. The 'We tried to use' language is a bit personal for a database connection test. Also JSON_TYPE is too specific here, we should just say JSON.

"Database connection does not support JSON." might be enough.

ankithashetty’s picture

Status: Needs work » Needs review
FileSize
2.07 KB
1.88 KB

Here is an updated patch, thanks!

daffie’s picture

Status: Needs review » Reviewed & tested by the community

The point of @catch has been addressed. Back to RTBC.

mondrake’s picture

Title: Fail if JSON is not supported by the database in Drupal 10 » Fail install if JSON is not supported by the database in Drupal 10

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 22: 3203193-22.patch, failed testing. View results

daffie’s picture

  • catch committed d214deb on 10.0.x
    Issue #3203193 by murilohp, ankithashetty, Gábor Hojtsy, daffie, catch:...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed d214deb and pushed to 10.0.x. Thanks!

xjm’s picture

Issue tags: +10.0.0 release notes

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.