Commit 29b39704 authored by Gábor Hojtsy's avatar Gábor Hojtsy
Browse files

Issue #3249178 by Gábor Hojtsy, daffie, mondrake, xurizaemon: Add a...

Issue #3249178 by Gábor Hojtsy, daffie, mondrake, xurizaemon: Add a requirements warning in Drupal 9 when PostgreSQL is used and the pg_trgm extension is not created
parent e1673423
Loading
Loading
Loading
Loading
+37 −0
Changes for src/Form/UpgradeStatusForm.php: 37 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -723,6 +723,43 @@ MARKUP
        ]
      ];

      // Check database version.
      $type = $this->database->databaseType();
      $version = $this->database->version();
      $addendum = '';
      if ($type == 'pgsql') {
        $type = 'PostgreSQL';
        $requirement = $this->t('When using PostgreSQL, minimum version is 12 <a href=":trgm">with the pg_trgm extension</a> created.', [':trgm' => 'https://www.postgresql.org/docs/10/pgtrgm.html']);
        $has_trgm = $this->database->query("SELECT installed_version FROM pg_available_extensions WHERE name = 'pg_trgm'")->fetchField();
        if (version_compare($version, '12') >= 0 && $has_trgm) {
          $class = 'no-known-error';
          $addendum = $this->t('Has pg_trgm extension.');
        }
        else {
          $status = FALSE;
          $class = 'known-error';
          if (!$has_trgm) {
            $addendum = $this->t('No pg_trgm extension.');
          }
        }
        $build['data']['#rows'][] = [
          'class' => [$class],
          'data' => [
            'requirement' => [
              'class' => 'requirement-label',
              'data' => [
                '#type' => 'markup',
                '#markup' => $requirement
              ],
            ],
            'status' => [
              'data' => trim($type . ' ' . $version . ' ' . $addendum),
              'class' => 'status-info',
            ],
          ]
        ];
      }

      // Check JSON support in database.
      $class = 'no-known-error';
      $requirement = $this->t('Supported.');