Problem/Motivation
For PostgreSQL in Drupal 10 will the pg_trgm extension be a requirement. The extension needs to be installed and created. Both must be done by a database user that has at least superuser privileges. The database user that is used by Drupal should not have those privileges. That would be a security risk.
Proposed resolution
Add a hook_requirements() that will throw an error when the extension is not installed and/or not created. The hook should already exist and should be changed from a warning to an error.
Remaining tasks
TBD
User interface changes
None
API changes
New method called Drupal\Core\Database\Driver\pgsql\Schema::extensionExists(string $name). Which returns true when the given extension name is installed and created or return false when that is not the case. This method should already exists.
Data model changes
None
Release notes snippet
Drupal 10's PostrgreSQL database driver requires PostgreSQL 12 with the pg_trgm extension enabled. A requirements error is now displayed when installing or updating a PostgreSQL site without this extension enabled.
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | interdiff_5-7.txt | 2.84 KB | murilohp |
| #7 | 3214922-7.patch | 5.51 KB | murilohp |
| #5 | 3214922-5.patch | 5.15 KB | murilohp |
Comments
Comment #2
gábor hojtsyMake target version clear in title, since we want to make a slightly different change in Drupal 9: #3214921: Add a requirements warning in Drupal 9 when PostgreSQL is used and the pg_trgm extension is not created. Also marking postponed since Drupal 10 is not yet opened. Also re-parenting for the beta requirements.
Comment #3
daffie commented#3214921: Add a requirements warning in Drupal 9 when PostgreSQL is used and the pg_trgm extension is not created has landed and the 10.0.x branch is open.
Comment #4
murilohp commentedComment #5
murilohp commentedHey, I was taking a look at this and write a patch to handle this situation, I made a little refactor on
core/modules/system/system.install, now the status page shows if the pg_trgm extension is enabled, this way I was able to write a test. I also created a new task function atcore/modules/pgsql/src/Driver/Database/pgsql/Install/Tasks.phpto handle extensions when installing a new site with postgres.Thanks!
Comment #6
daffie commentedThe patch looks very good!
Just 1 remark:
You cannot add this here. You can only add this after
Database::isActiveConnection(). There might not be a database connection and an exception will be thrown.Comment #7
murilohp commentedFixing the coding standards and addressing #6 thanks @daffie!
Comment #8
murilohp commentedComment #9
daffie commentedAll code changes look good to me.
I do not see how we can add more testing for the changes.
For me it is RTBC.
@murilohp: Thank you for working on this.
Comment #10
catchCommitted b74bb8f and pushed to 10.0.x. Thanks!
Comment #12
xjmThis warning is new since alpha1, and is enforcing the platform requirement that will be documented in the 10.0.0 notes as well.
Comment #13
xjmAdded release note.
Comment #14
catchLinked the existing CR from the release note.