// Check JSON support in database.
      $class = 'no-known-error';
      $requirement = $this->t('Supported.');
      try {
        +if (!method_exists($this->database, 'hasJson') || !$this->database->hasJson()) {
          // A hasJson() method was added to Connection from Drupal 9.4.0
          // but we cannot rely on being on Drupal 9.4.x+
          $this->database->query($database_type == 'pgsql' ? 'SELECT JSON_TYPEOF(\'1\')' : 'SELECT JSON_TYPE(\'1\')');
        +}
      }
      catch (\Exception $e) {
        $class = 'known-error';
        $status = FALSE;
        $requirement = $this->t('Not supported.');
      }
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Fabianx created an issue. See original summary.

rpayanm made their first commit to this issue’s fork.

gábor hojtsy’s picture

Suggested code looks good. Sent for a test on all the environments.

  • a71aaff committed on 8.x-3.x
    Issue #3282447 by rpayanm, Fabianx: Use hasJson method if it exists (...
gábor hojtsy’s picture

Status: Needs review » Fixed
Issue tags: -needs patch

Committed. I did not commit the unrelated code style suggestion though, let's keep history clear :)

Status: Fixed » Closed (fixed)

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