- Issue created by @agentrickard
- ๐ฎ๐ณIndia samir_shukla bareilly
Hi, instead of using getDatabaseConnection, we can use Database::getConnection(): https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Database%...
use Drupal\Core\Database\Database. $this->database = Database::getConnection();
where the default database is your Drupal database, and if you want to define a specific database you can use as:
$dbh = Database::getConnection('default', 'SQL');
and define that db in your settings.php :$databases['SQL']['default'] = array( 'database' => "test", 'username' => "root", 'password' => "root", 'host' => $host, 'driver' => $driver, 'port' => $port, 'prefix' => "", );
- ๐ฎ๐ณIndia samir_shukla bareilly
Here is the patch for the same if it helps.
- Status changed to Needs review
12 months ago 7:37am 3 January 2024 - ๐ช๐ธSpain guiu.rocafort.ferrer Barcelona
guiu.rocafort.ferrer โ made their first commit to this issueโs fork.
- ๐ช๐ธSpain guiu.rocafort.ferrer Barcelona
Thank you for having a look at it @samir_shukla
After having a look at this issue ( https://www.drupal.org/project/drupal/issues/2991337 ๐ Document the recommended ways to obtain the database connection object Needs work ), i believe that the preferred way of accessing the database connection is:
$this->container->get('database');
Also see: https://www.drupal.org/docs/drupal-apis/database-api/instantiating-a-dat... โ
I created a merge branch, and added the change there, so it can be merged to the main dev branch easily.
- Status changed to Needs work
12 months ago 6:52pm 8 January 2024 - ๐บ๐ธUnited States agentrickard Georgia (US)
It looks like the default branch on the fork is 8.x-1.x so the tests didn't run.
I had to update GitLab to use the correct default branch, so this MR needs to be redone.
- Merge request !62Issue #3411052 : Removed TestSetupTrait::getDatabaseConnection for ->container->get('database') โ (Open) created by guiu.rocafort.ferrer
- ๐ช๐ธSpain guiu.rocafort.ferrer Barcelona
I checked the issue branch and the commit for adding the Gitlab CI was present already. The branch was forked from the 2.0.x branch, so i just created a new merge agains the 2.0.x branch and the CI seems to be running now.
The thing now is that 4 phpunit tests are failing, but i cannot seem to reproduce them in my local environment.
- ๐ช๐ธSpain guiu.rocafort.ferrer Barcelona
So, one of the errors is because they changed the save button label in the create content type form, now it just says "Save" instead of "Save content type".
The other 3 errors seem related to this issue https://www.drupal.org/project/drupal/issues/3316274 ๐ Stabilize FunctionalJavascript testing AJAX: add ::assertExpectedAjaxRequest() Fixed
Since none of the errors are related with the issue, would it be safe to merge them, and tackle those in different issues ?
- Status changed to Needs review
11 months ago 2:02pm 27 January 2024 - ๐ช๐ธSpain guiu.rocafort.ferrer Barcelona
Changing the issue status to needs review.
- Status changed to Closed: outdated
5 months ago 2:38pm 21 July 2024 The issue was fixed in https://www.drupal.org/project/domain/issues/3457913 ๐ Fix GitLab failures Fixed .