Skip to content
This repository has been archived by the owner on Jan 2, 2025. It is now read-only.

Commit

Permalink
Fix for #3217531 Deprecate usage of Connection::getDriverClass for so…
Browse files Browse the repository at this point in the history
…me classes (#329)
  • Loading branch information
mondrake authored Jul 21, 2023
1 parent 51d500e commit f2a8640
Show file tree
Hide file tree
Showing 2 changed files with 145 additions and 117 deletions.
182 changes: 86 additions & 96 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,102 +5,92 @@ on:
branches: [ master ]

env:
DRUDBAL_DRUPAL_VERSION: "11.x"
DRUDBAL_DRUPAL_PROFILE: "standard"
SIMPLETEST_BASE_URL: "http://localhost:8080"
PHPUNIT_SKIP_CLASS: '[
"Drupal\\KernelTests\\Core\\Cache\\ApcuBackendTest",
"Drupal\\Tests\\file\\Functional\\FileAddPermissionsUpdateTest"
]'
DRUDBAL_DRUPAL_VERSION: "11.x"
DRUDBAL_DRUPAL_PROFILE: "standard"
SIMPLETEST_BASE_URL: "http://localhost:8080"
PHPUNIT_SKIP_CLASS: '[
"Drupal\\KernelTests\\Core\\Cache\\ApcuBackendTest",
"Drupal\\Tests\\file\\Functional\\FileAddPermissionsUpdateTest"
]'

jobs:

#################################

oracle-oci8:
name: "Oracle on Oci8"
runs-on: ubuntu-20.04
env:
DRUDBAL_ENV: "dbal/oci8"
DBAL_URL: "oci8://DRUDBAL:[email protected]:1521/XE"
SIMPLETEST_DB: "dbal://DRUDBAL:[email protected]:1521/XE?module=drudbal&dbal_driver=oci8#dru"

services:
oracle:
image: gvenzl/oracle-xe:slim-faststart
env:
ORACLE_PASSWORD: oracle
ports:
- "1521:1521"
options: >-
--health-cmd healthcheck.sh
--health-interval 20s
--health-timeout 10s
--health-retries 10
strategy:
fail-fast: false
matrix:
php-version:
- "8.2"
test-args:
- "--group Database"
# - "--group Entity"
# - "--group Cache,Config"
# - "--group field,Field"
# - "--group file"
# - "--group views"

steps:
- name: Install PHP
uses: "shivammathur/setup-php@v2"
with:
php-version: "${{ matrix.php-version }}"
coverage: "none"
extensions: "oci8"
ini-values: "zend.assertions=1"

- name: Checkout Drupal
run: git clone --depth=5 --branch=$DRUDBAL_DRUPAL_VERSION http://git.drupal.org/project/drupal.git .

- name: Checkout DruDbal
uses: actions/checkout@v3
with:
path: drudbal_staging

- name: Patch Drupal
run: ./drudbal_staging/tests/github/drupal_patch.sh

- name: Install Composer dependencies
run: |
composer install --no-progress --ansi
composer config --no-plugins allow-plugins.composer/package-versions-deprecated true
- name: Composer require DruDbal from local staging
run: |
git -C drudbal_staging checkout -b test-run-branch
composer config repositories.test-run '{"type": "path", "url": "drudbal_staging", "options": {"symlink": false}}'
composer require "mondrake/drudbal:dev-test-run-branch" --no-progress --ansi
- name: Create Oracle schema
run: |
cp modules/contrib/drudbal/tests/github/install_* .
php install_oracle.php
- name: Install Drupal
continue-on-error: true
run: |
vendor/bin/drush site-install standard --db-url=$SIMPLETEST_DB -y
vendor/bin/drush runserver localhost:8080 --default-server=localhost:8080 &
sleep 5s
- name: Report installation
continue-on-error: true
run: |
php install_report.php
vendor/bin/drush core:status
vendor/bin/drush core:requirements
vendor/bin/drush pml --type=module --no-core
- name: Run test ${{ matrix.test-args }}
run: vendor/bin/phpunit -c core --color=always ${{ matrix.test-args }}
#################################

mysql-pdo:
name: "MySql"
runs-on: ubuntu-latest
env:
DRUDBAL_ENV: "dbal/mysql"
DBAL_URL: "mysql://root:@0.0.0.0:3306/drudbal"
SIMPLETEST_DB: "dbal://root:@0.0.0.0:3306/drudbal?module=drudbal&dbal_driver=pdo_mysql"

strategy:
fail-fast: false
matrix:
php-version:
- "8.2"
test-args:
- "--group Database"
# - "--group Entity"
# - "--group Cache,Config"
# - "--group field,Field"
# - "--group file"
# - "--group views"

services:
mysql:
image: "mysql:5.7"
options: >-
-e MYSQL_ALLOW_EMPTY_PASSWORD=yes
-e MYSQL_DATABASE=drudbal
ports:
- "3306:3306"

steps:
- name: Install PHP
uses: "shivammathur/setup-php@v2"
with:
php-version: "${{ matrix.php-version }}"
coverage: "none"
extensions: "pdo_mysql"
ini-values: "zend.assertions=1"

- name: Checkout Drupal
run: git clone --depth=5 --branch=$DRUDBAL_DRUPAL_VERSION http://git.drupal.org/project/drupal.git .

- name: Checkout DruDbal
uses: actions/checkout@v3
with:
path: drudbal_staging

- name: Patch Drupal
run: ./drudbal_staging/tests/github/drupal_patch.sh

- name: Install Composer dependencies
run: |
composer install --no-progress --ansi
composer config --no-plugins allow-plugins.composer/package-versions-deprecated true
- name: Composer require DruDbal from local staging
run: |
git -C drudbal_staging checkout -b test-run-branch
composer config repositories.test-run '{"type": "path", "url": "drudbal_staging", "options": {"symlink": false}}'
composer require "mondrake/drudbal:dev-test-run-branch" --no-progress --ansi
- name: Install Drupal
run: |
cp modules/contrib/drudbal/tests/github/install_* .
vendor/bin/drush site-install standard --db-url=$SIMPLETEST_DB -y
vendor/bin/drush runserver localhost:8080 --default-server=localhost:8080 &
sleep 1s
- name: Report installation
run: |
php install_report.php
vendor/bin/drush core:status
vendor/bin/drush core:requirements
vendor/bin/drush pml --type=module --no-core
- name: Run test ${{ matrix.test-args }}
run: vendor/bin/phpunit -c core --color=always ${{ matrix.test-args }}
80 changes: 59 additions & 21 deletions src/Driver/Database/dbal/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@

namespace Drupal\drudbal\Driver\Database\dbal;

use Drupal\Core\Utility\Error;
use Composer\InstalledVersions;
use Doctrine\DBAL\Connection as DbalConnection;
use Doctrine\DBAL\ConnectionException as DbalConnectionException;
use Doctrine\DBAL\Exception as DbalException;
use Doctrine\DBAL\DriverManager as DbalDriverManager;
use Doctrine\DBAL\Exception as DbalException;
use Doctrine\DBAL\Exception\DriverException as DbalDriverException;
use Doctrine\DBAL\ExpandArrayParameters;
use Doctrine\DBAL\Platforms\AbstractPlatform as DbalAbstractPlatform;
Expand All @@ -19,11 +18,14 @@
use Drupal\Core\Database\Database;
use Drupal\Core\Database\DatabaseExceptionWrapper;
use Drupal\Core\Database\DatabaseNotFoundException;
use Drupal\Core\Database\Query\Condition;
use Drupal\Core\Database\StatementInterface;
use Drupal\Core\Database\Transaction;
use Drupal\Core\Database\TransactionCommitFailedException;
use Drupal\Core\Database\TransactionNameNonUniqueException;
use Drupal\Core\Database\TransactionNoActiveException;
use Drupal\Core\Database\TransactionOutOfOrderException;
use Drupal\Core\Utility\Error;
use Drupal\drudbal\Driver\Database\dbal\DbalExtension\DbalExtensionInterface;
use Drupal\drudbal\Driver\Database\dbal\DbalExtension\MysqliExtension;
use Drupal\drudbal\Driver\Database\dbal\DbalExtension\Oci8Extension;
Expand Down Expand Up @@ -186,25 +188,6 @@ public function lastInsertId(?string $name = NULL): string {
return (string) $this->getDbalConnection()->lastInsertId($name);
}

/**
* {@inheritdoc}
*/
public function exceptionHandler() {
return new ExceptionHandler($this);
}

/**
* {@inheritdoc}
*/
public function schema(): Schema {
if (!isset($this->schema)) {
$this->schema = new Schema($this);
}
$schema = $this->schema;
assert($schema instanceof Schema);
return $schema;
}

/**
* {@inheritdoc}
*/
Expand Down Expand Up @@ -700,4 +683,59 @@ public function query($query, array $args = [], $options = []) {
return parent::query($query, $args, $options);
}

public function exceptionHandler() {
return new ExceptionHandler($this);
}

public function select($table, $alias = NULL, array $options = []) {
return new Select($this, $table, $alias, $options);
}

public function insert($table, array $options = []) {
return new Insert($this, $table, $options);
}

public function merge($table, array $options = []) {
return new Merge($this, $table, $options);
}

public function upsert($table, array $options = []) {
return new Upsert($this, $table, $options);
}

public function update($table, array $options = []) {
return new Update($this, $table, $options);
}

public function delete($table, array $options = []) {
return new Delete($this, $table, $options);
}

public function truncate($table, array $options = []) {
return new Truncate($this, $table, $options);
}

public function schema(): Schema {
if (!isset($this->schema)) {
$this->schema = new Schema($this);
}
$schema = $this->schema;
assert($schema instanceof Schema);
return $schema;
}

/**
* @todo remove in D11
*/
public function condition($conjunction) {
return new Condition($conjunction);
}

/**
* @todo remove in D11
*/
public function startTransaction($name = '') {
return new Transaction($this, $name);
}

}

0 comments on commit f2a8640

Please sign in to comment.