Database connections are opened based on some configuration (the 'connection options') that are present in the settings.php file or in URI for the case of tests or CLI access.
There is no control/validation of what these options include at the moment.
A new value object, implementing ConnectionParametersInterface, is introduced and will progressively remove the usage of the array-based connection options internally within the Database API.
- Introduce
ConnectionParametersInterfaceand an abstract base class implementationConnectionParametersBase - The SQLite driver implemented the new class
- To support BC, db drivers that implement a
ConnectionParametersclass will start using the new logic, those that don't will get a closure wrapper implementation ofConnectionParametersBasethat provides access to the options array - For the moment, allow read-only array access to the parameters in the new class - this can be deprecated once all drivers are converted
- Deprecate
Database::getConnectionInfoAsUrl()andConnection::createUrlFromConnectionOptions()as now the URL version of the parameters can be got from the object directly.
Database drivers should implement their own ConnectionParameters class, extending the base one. Only public readonly properties in the implementation will be considered valid parameters when parsing the array from settings.php. Options from the array in the file that the driver does not need are stored, for BC, in a $unknownOptions array. Future developments may tighten the validations and checks of such options, as well as drop the array access to the options that is retained for BC.
Developers of unit tests may need to adjust their tests, as the minimum set of options to be passed to a connection is now driver, module, database, prefix, namespace and autoload info.