From c15b6ae40138b14091638c1452903d4c969ee27a Mon Sep 17 00:00:00 2001 From: mondrake Date: Thu, 8 Jun 2023 14:32:49 +0200 Subject: [PATCH 01/13] Update pr.yml --- .github/workflows/pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index b9b60489..44632027 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -5,7 +5,7 @@ on: branches: [ master ] env: - DRUDBAL_DRUPAL_VERSION: "10.1.x" + DRUDBAL_DRUPAL_VERSION: "11.x" DRUDBAL_DRUPAL_PROFILE: "standard" SIMPLETEST_BASE_URL: "http://localhost:8080" PHPUNIT_SKIP_CLASS: '[ From 089f15b36a0bfdc4d4d6793481bed46462e9caa9 Mon Sep 17 00:00:00 2001 From: mondrake Date: Thu, 8 Jun 2023 14:37:43 +0200 Subject: [PATCH 02/13] Update composer.json --- composer.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 1282795e..8822b555 100644 --- a/composer.json +++ b/composer.json @@ -5,9 +5,9 @@ "license": "LGPL-3.0-or-later", "require": { "php": ">=8.1", - "drupal/core": "^10.1", - "doctrine/dbal": "^3.5", - "drush/drush": "^11", + "drupal/core": "^11", + "doctrine/dbal": "^3.6", + "drush/drush": "^12", "composer-runtime-api": "^2.0.0" }, "autoload": { From 2edc0a3104230bc5d845d9154f070d0895485234 Mon Sep 17 00:00:00 2001 From: mondrake Date: Thu, 8 Jun 2023 14:43:39 +0200 Subject: [PATCH 03/13] Update drudbal.info.yml --- drudbal.info.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drudbal.info.yml b/drudbal.info.yml index 496025ae..efe20913 100644 --- a/drudbal.info.yml +++ b/drudbal.info.yml @@ -1,5 +1,5 @@ type: module -core_version_requirement: ^10.1 +core_version_requirement: ^10.1 | ^11 name: DruDbal description: 'Drupal driver for Doctrine DBAL.' lifecycle: experimental From 7436984340a4b82ae0afbda5188851b93b028483 Mon Sep 17 00:00:00 2001 From: mondrake Date: Thu, 8 Jun 2023 18:30:25 +0200 Subject: [PATCH 04/13] fixes --- .github/workflows/code-check.yml | 2 +- .github/workflows/mysql.yml | 2 +- .github/workflows/mysqli.yml | 2 +- .github/workflows/oracle.yml | 2 +- .github/workflows/sqlite.yml | 2 +- README.md | 2 +- drudbal.info.yml | 2 +- src/Driver/Database/dbal/Connection.php | 1 + .../Database/dbal/DbalExtension/AbstractExtension.php | 3 ++- .../dbal/DbalExtension/AbstractMySqlExtension.php | 2 ++ .../dbal/DbalExtension/DbalExtensionInterface.php | 2 ++ .../Database/dbal/DbalExtension/Oci8Extension.php | 1 + .../dbal/DbalExtension/PDOSqliteExtension.php | 11 +++++++++-- 13 files changed, 24 insertions(+), 10 deletions(-) diff --git a/.github/workflows/code-check.yml b/.github/workflows/code-check.yml index aa6e0599..eb94fce0 100644 --- a/.github/workflows/code-check.yml +++ b/.github/workflows/code-check.yml @@ -9,7 +9,7 @@ on: - cron: "0 6 * * 2" env: - DRUDBAL_DRUPAL_VERSION: "10.1.x" + DRUDBAL_DRUPAL_VERSION: "11.x" jobs: diff --git a/.github/workflows/mysql.yml b/.github/workflows/mysql.yml index 8b305cde..37d4d6d0 100644 --- a/.github/workflows/mysql.yml +++ b/.github/workflows/mysql.yml @@ -7,7 +7,7 @@ on: - cron: "0 6 * * 2" env: - DRUDBAL_DRUPAL_VERSION: "10.1.x" + DRUDBAL_DRUPAL_VERSION: "11.x" DRUDBAL_DRUPAL_PROFILE: "standard" SIMPLETEST_BASE_URL: "http://localhost:8080" PHPUNIT_SKIP_CLASS: '[ diff --git a/.github/workflows/mysqli.yml b/.github/workflows/mysqli.yml index 51b12171..0e068b2e 100644 --- a/.github/workflows/mysqli.yml +++ b/.github/workflows/mysqli.yml @@ -7,7 +7,7 @@ on: - cron: "0 6 * * 2" env: - DRUDBAL_DRUPAL_VERSION: "10.1.x" + DRUDBAL_DRUPAL_VERSION: "11.x" DRUDBAL_DRUPAL_PROFILE: "standard" SIMPLETEST_BASE_URL: "http://localhost:8080" PHPUNIT_SKIP_CLASS: '[ diff --git a/.github/workflows/oracle.yml b/.github/workflows/oracle.yml index 45512189..a45d71ea 100644 --- a/.github/workflows/oracle.yml +++ b/.github/workflows/oracle.yml @@ -7,7 +7,7 @@ on: - cron: "0 6 * * 2" env: - DRUDBAL_DRUPAL_VERSION: "10.1.x" + DRUDBAL_DRUPAL_VERSION: "11.x" DRUDBAL_DRUPAL_PROFILE: "standard" SIMPLETEST_BASE_URL: "http://localhost:8080" PHPUNIT_SKIP_CLASS: '[ diff --git a/.github/workflows/sqlite.yml b/.github/workflows/sqlite.yml index a36b6f69..bc1986b1 100644 --- a/.github/workflows/sqlite.yml +++ b/.github/workflows/sqlite.yml @@ -7,7 +7,7 @@ on: - cron: "0 6 * * 2" env: - DRUDBAL_DRUPAL_VERSION: "10.1.x" + DRUDBAL_DRUPAL_VERSION: "11.x" DRUDBAL_DRUPAL_PROFILE: "standard" SIMPLETEST_BASE_URL: "http://localhost:8080" PHPUNIT_SKIP_CLASS: '[ diff --git a/README.md b/README.md index 7ebdd84e..4cbe3223 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,7 @@ under the hood: 1. Requirements: * PHP 8.1+ - * latest Drupal development branch code, 10.1.x + * latest Drupal development branch code, 11.x * codebase built via Composer 2. Get the DruDbal module from Packagist via Composer, it will install Doctrine diff --git a/drudbal.info.yml b/drudbal.info.yml index efe20913..21514c59 100644 --- a/drudbal.info.yml +++ b/drudbal.info.yml @@ -1,5 +1,5 @@ type: module -core_version_requirement: ^10.1 | ^11 +core_version_requirement: ^11 name: DruDbal description: 'Drupal driver for Doctrine DBAL.' lifecycle: experimental diff --git a/src/Driver/Database/dbal/Connection.php b/src/Driver/Database/dbal/Connection.php index 45a21d2a..c3019e76 100644 --- a/src/Driver/Database/dbal/Connection.php +++ b/src/Driver/Database/dbal/Connection.php @@ -364,6 +364,7 @@ public function mapConditionOperator($operator) { * {@inheritdoc} */ public function nextId($existing_id = 0) { + @trigger_error('Drupal\Core\Database\Connection::nextId() is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Modules should use instead the keyvalue storage for the last used id. See https://www.drupal.org/node/3349345', E_USER_DEPRECATED); $id = is_numeric($existing_id ?? 0) ? ($existing_id ?? 0) : 0; return $this->dbalExtension->delegateNextId($id); } diff --git a/src/Driver/Database/dbal/DbalExtension/AbstractExtension.php b/src/Driver/Database/dbal/DbalExtension/AbstractExtension.php index 72051234..f757b24d 100644 --- a/src/Driver/Database/dbal/DbalExtension/AbstractExtension.php +++ b/src/Driver/Database/dbal/DbalExtension/AbstractExtension.php @@ -226,7 +226,8 @@ public function delegateMapConditionOperator(string $operator): ?array { * {@inheritdoc} */ public function delegateNextId(int $existing_id = 0): int { - throw new \LogicException("Method " . __METHOD__ . " not implemented."); + @trigger_error(__METHOD__ . '() is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Modules should use instead the keyvalue storage for the last used id. See https://www.drupal.org/node/3349345', E_USER_DEPRECATED); + throw new \LogicException("Method " . __METHOD__ . " not implemented."); } /** diff --git a/src/Driver/Database/dbal/DbalExtension/AbstractMySqlExtension.php b/src/Driver/Database/dbal/DbalExtension/AbstractMySqlExtension.php index ec35bdd8..60da837d 100644 --- a/src/Driver/Database/dbal/DbalExtension/AbstractMySqlExtension.php +++ b/src/Driver/Database/dbal/DbalExtension/AbstractMySqlExtension.php @@ -204,6 +204,7 @@ public function postCreateDatabase($database_name) { * {@inheritdoc} */ public function delegateNextId(int $existing_id = 0): int { + @trigger_error(__METHOD__ . '() is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Modules should use instead the keyvalue storage for the last used id. See https://www.drupal.org/node/3349345', E_USER_DEPRECATED); $this->connection->query('INSERT INTO {sequences} () VALUES ()'); $new_id = $this->connection->lastInsertId(); // This should only happen after an import or similar event. @@ -227,6 +228,7 @@ public function delegateNextId(int $existing_id = 0): int { * Cleanup next ID. */ protected function nextIdDelete() { + @trigger_error(__METHOD__ . '() is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Modules should use instead the keyvalue storage for the last used id. See https://www.drupal.org/node/3349345', E_USER_DEPRECATED); // While we want to clean up the table to keep it up from occupying too // much storage and memory, we must keep the highest value in the table // because InnoDB uses an in-memory auto-increment counter as long as the diff --git a/src/Driver/Database/dbal/DbalExtension/DbalExtensionInterface.php b/src/Driver/Database/dbal/DbalExtension/DbalExtensionInterface.php index 9d0ee3db..56f9d40d 100644 --- a/src/Driver/Database/dbal/DbalExtension/DbalExtensionInterface.php +++ b/src/Driver/Database/dbal/DbalExtension/DbalExtensionInterface.php @@ -281,6 +281,8 @@ public function delegateMapConditionOperator(string $operator): ?array; * @return int * An integer number larger than any number returned by earlier calls and * also larger than the $existing_id if one was passed in. + * + * @deprecated */ public function delegateNextId(int $existing_id = 0): int; diff --git a/src/Driver/Database/dbal/DbalExtension/Oci8Extension.php b/src/Driver/Database/dbal/DbalExtension/Oci8Extension.php index ebc9cbed..879dce51 100644 --- a/src/Driver/Database/dbal/DbalExtension/Oci8Extension.php +++ b/src/Driver/Database/dbal/DbalExtension/Oci8Extension.php @@ -223,6 +223,7 @@ public function delegateMapConditionOperator(string $operator): ?array { * {@inheritdoc} */ public function delegateNextId(int $existing_id = 0): int { + @trigger_error(__METHOD__ . '() is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Modules should use instead the keyvalue storage for the last used id. See https://www.drupal.org/node/3349345', E_USER_DEPRECATED); // @codingStandardsIgnoreLine $trn = $this->connection->startTransaction(); $stmt = $this->connection->prepareStatement('UPDATE {sequences} SET [value] = GREATEST([value], :existing_id) + 1', [], TRUE); diff --git a/src/Driver/Database/dbal/DbalExtension/PDOSqliteExtension.php b/src/Driver/Database/dbal/DbalExtension/PDOSqliteExtension.php index 5154a5fd..d0e82bee 100644 --- a/src/Driver/Database/dbal/DbalExtension/PDOSqliteExtension.php +++ b/src/Driver/Database/dbal/DbalExtension/PDOSqliteExtension.php @@ -15,6 +15,7 @@ use Drupal\drudbal\Driver\Database\dbal\Connection as DruDbalConnection; use Drupal\drudbal\Driver\Database\dbal\Statement\PrefetchingStatementWrapper; use Drupal\sqlite\Driver\Database\sqlite\Connection as SqliteConnectionBase; +use Symfony\Component\Filesystem\Exception\IOException; use Symfony\Component\Filesystem\Filesystem; /** @@ -340,8 +341,13 @@ public function delegateTransactionalDdlSupport(array &$connection_options = []) public function preCreateDatabase($database_name) { // Verify the database is writable. $db_directory = new \SplFileInfo(dirname($database_name)); - if (!$db_directory->isDir() && !(new Filesystem())->mkdir($db_directory->getPathName(), 0755)) { - throw new DatabaseNotFoundException('Unable to create database directory ' . $db_directory->getPathName()); + if (!$db_directory->isDir()) { + try { + (new Filesystem())->mkdir($db_directory->getPathName(), 0755); + } + catch (IOException $e) { + throw new DatabaseNotFoundException('Unable to create database directory ' . $db_directory->getPathName(), $e->getCode(), $e); + } } return $this; } @@ -357,6 +363,7 @@ public function delegateMapConditionOperator(string $operator): ?array { * {@inheritdoc} */ public function delegateNextId(int $existing_id = 0): int { + @trigger_error(__METHOD__ . '() is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Modules should use instead the keyvalue storage for the last used id. See https://www.drupal.org/node/3349345', E_USER_DEPRECATED); // @codingStandardsIgnoreLine $trn = $this->connection->startTransaction(); From aec3ffa43994b8eabc4f63e2ed8bbef435bb121b Mon Sep 17 00:00:00 2001 From: mondrake Date: Fri, 16 Jun 2023 22:03:25 +0200 Subject: [PATCH 05/13] adjust post #3256642 --- .github/workflows/pr.yml | 181 ++++++++++++++++------------------- README.md | 1 - tests/github/drupal_patch.sh | 3 - 3 files changed, 81 insertions(+), 104 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 44632027..6371d9f8 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -4,104 +4,85 @@ on: pull_request: 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", - "Drupal\\KernelTests\\Core\\Database\\SchemaUniquePrefixedKeysIndexTest" - ]' - -jobs: - -################################# - - oracle-oci8: - name: "Oracle on Oci8" - runs-on: ubuntu-20.04 env: - DRUDBAL_ENV: "dbal/oci8" - DBAL_URL: "oci8://DRUDBAL:ORACLE@0.0.0.0:1521/XE" - SIMPLETEST_DB: "dbal://DRUDBAL:ORACLE@0.0.0.0: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: -# - "-v modules/contrib/drudbal/tests/src/Kernel/dbal/SchemaTest.php" - - "--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 - 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 }} + 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", + "Drupal\\Tests\\file\\Functional\\DownloadTest", + "Drupal\\KernelTests\\Core\\Database\\SchemaUniquePrefixedKeysIndexTest" + ]' + + jobs: + + ################################# + + sqlite-pdo: + name: "SQLite with PDO" + runs-on: ubuntu-20.04 + env: + DRUDBAL_ENV: "dbal/sqlite/file" + DBAL_URL: "sqlite://localhost/sites/drudbal.sqlite" + SIMPLETEST_DB: "dbal://localhost/sites/drudbal.sqlite?module=drudbal&dbal_driver=pdo_sqlite" + + strategy: + fail-fast: false + matrix: + php-version: +# - "8.1" + - "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" + 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 + + - 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 }} diff --git a/README.md b/README.md index 4cbe3223..7754b1c5 100644 --- a/README.md +++ b/README.md @@ -93,6 +93,5 @@ tbd | Add tests for tbd | Ensure that when INSERTing a NULL value in a database column, SELECTing it back returns NULL and not empty string - for all fetch modes | tbd | UpdateTestBase::runUpdate should reset database schema after updating | [#2992274](https://www.drupal.org/project/drupal/issues/2992274) | Installer tests fail if contrib driver hides database credentials form fields | -[#3256642](https://www.drupal.org/project/drupal/issues/3256642) | Autoload classes of database drivers modules' dependencies | [#3347497](https://www.drupal.org/project/drupal/issues/3347497) | Introduce a FetchModeTrait to allow emulating PDO fetch modes | [#3355841](https://www.drupal.org/project/drupal/issues/3355841) | Allow DriverSpecificSchemaTestBase::testChangePrimaryKeyToSerial to execute for non-core drivers | diff --git a/tests/github/drupal_patch.sh b/tests/github/drupal_patch.sh index 5fc5b309..9cf3c2d5 100755 --- a/tests/github/drupal_patch.sh +++ b/tests/github/drupal_patch.sh @@ -3,9 +3,6 @@ #3110546 Allow contributed modules (mostly database drivers) to override tests in core curl https://git.drupalcode.org/project/drupal/-/merge_requests/291.diff | git apply -v -#3256642 Introduce database driver extensions and autoload database drivers' dependencies -curl https://git.drupalcode.org/project/drupal/-/merge_requests/3169.diff | git apply -v - #2992274 Installer tests fail if contrib driver hides database credentials form fields # curl https://www.drupal.org/files/issues/2022-06-01/2992274-25.patch | git apply -v git apply -v ./drudbal_staging/tests/github/2992274-local.patch From c98a51a87bd72a14b652eabc1d6303d729e29b84 Mon Sep 17 00:00:00 2001 From: mondrake Date: Fri, 16 Jun 2023 22:06:59 +0200 Subject: [PATCH 06/13] II --- .github/workflows/pr.yml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 6371d9f8..d4ceb678 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -4,18 +4,18 @@ on: pull_request: 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", - "Drupal\\Tests\\file\\Functional\\DownloadTest", - "Drupal\\KernelTests\\Core\\Database\\SchemaUniquePrefixedKeysIndexTest" - ]' +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", + "Drupal\\Tests\\file\\Functional\\DownloadTest", + "Drupal\\KernelTests\\Core\\Database\\SchemaUniquePrefixedKeysIndexTest" + ]' - jobs: +jobs: ################################# From c8b98992ca93eee4b45b8ece19a9bbc37cee2fd0 Mon Sep 17 00:00:00 2001 From: mondrake Date: Sun, 18 Jun 2023 18:30:13 +0200 Subject: [PATCH 07/13] add SchemaUniquePrefixedKeysIndexTest --- .github/workflows/oracle.yml | 3 +-- .github/workflows/pr.yml | 3 +-- .github/workflows/sqlite.yml | 3 +-- .../SchemaUniquePrefixedKeysIndexTest.php | 19 +++++++++++++++++++ 4 files changed, 22 insertions(+), 6 deletions(-) create mode 100644 tests/src/Kernel/dbal/SchemaUniquePrefixedKeysIndexTest.php diff --git a/.github/workflows/oracle.yml b/.github/workflows/oracle.yml index a45d71ea..539906f9 100644 --- a/.github/workflows/oracle.yml +++ b/.github/workflows/oracle.yml @@ -12,8 +12,7 @@ env: SIMPLETEST_BASE_URL: "http://localhost:8080" PHPUNIT_SKIP_CLASS: '[ "Drupal\\KernelTests\\Core\\Cache\\ApcuBackendTest", - "Drupal\\Tests\\file\\Functional\\FileAddPermissionsUpdateTest", - "Drupal\\KernelTests\\Core\\Database\\SchemaUniquePrefixedKeysIndexTest" + "Drupal\\Tests\\file\\Functional\\FileAddPermissionsUpdateTest" ]' jobs: diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index d4ceb678..cda934ef 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -11,8 +11,7 @@ env: PHPUNIT_SKIP_CLASS: '[ "Drupal\\KernelTests\\Core\\Cache\\ApcuBackendTest", "Drupal\\Tests\\file\\Functional\\FileAddPermissionsUpdateTest", - "Drupal\\Tests\\file\\Functional\\DownloadTest", - "Drupal\\KernelTests\\Core\\Database\\SchemaUniquePrefixedKeysIndexTest" + "Drupal\\Tests\\file\\Functional\\DownloadTest" ]' jobs: diff --git a/.github/workflows/sqlite.yml b/.github/workflows/sqlite.yml index bc1986b1..d6920466 100644 --- a/.github/workflows/sqlite.yml +++ b/.github/workflows/sqlite.yml @@ -13,8 +13,7 @@ env: PHPUNIT_SKIP_CLASS: '[ "Drupal\\KernelTests\\Core\\Cache\\ApcuBackendTest", "Drupal\\Tests\\file\\Functional\\FileAddPermissionsUpdateTest", - "Drupal\\Tests\\file\\Functional\\DownloadTest", - "Drupal\\KernelTests\\Core\\Database\\SchemaUniquePrefixedKeysIndexTest" + "Drupal\\Tests\\file\\Functional\\DownloadTest" ]' jobs: diff --git a/tests/src/Kernel/dbal/SchemaUniquePrefixedKeysIndexTest.php b/tests/src/Kernel/dbal/SchemaUniquePrefixedKeysIndexTest.php new file mode 100644 index 00000000..995f3eb1 --- /dev/null +++ b/tests/src/Kernel/dbal/SchemaUniquePrefixedKeysIndexTest.php @@ -0,0 +1,19 @@ + Date: Sun, 18 Jun 2023 19:46:30 +0200 Subject: [PATCH 08/13] I --- .github/workflows/pr.yml | 3 ++- src/Driver/Database/dbal/DbalExtension/AbstractExtension.php | 2 +- tests/src/Kernel/dbal/SchemaUniquePrefixedKeysIndexTest.php | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index cda934ef..bba7dda8 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -33,7 +33,8 @@ jobs: # - "8.1" - "8.2" test-args: - - "--group Database" + - "--group Databasexx" +# - "--group Database" # - "--group Entity" # - "--group Cache,Config" # - "--group field,Field" diff --git a/src/Driver/Database/dbal/DbalExtension/AbstractExtension.php b/src/Driver/Database/dbal/DbalExtension/AbstractExtension.php index f757b24d..89f2f1b5 100644 --- a/src/Driver/Database/dbal/DbalExtension/AbstractExtension.php +++ b/src/Driver/Database/dbal/DbalExtension/AbstractExtension.php @@ -26,7 +26,7 @@ class AbstractExtension implements DbalExtensionInterface { /** * Enables debugging. */ - protected static bool $isDebugging = FALSE; + protected static bool $isDebugging = TRUE; /** * Constructs a DBAL extension object. diff --git a/tests/src/Kernel/dbal/SchemaUniquePrefixedKeysIndexTest.php b/tests/src/Kernel/dbal/SchemaUniquePrefixedKeysIndexTest.php index 995f3eb1..b4b83922 100644 --- a/tests/src/Kernel/dbal/SchemaUniquePrefixedKeysIndexTest.php +++ b/tests/src/Kernel/dbal/SchemaUniquePrefixedKeysIndexTest.php @@ -7,7 +7,7 @@ /** * Tests adding UNIQUE keys to tables. * - * @group Database + * @group Databasexx */ class SchemaUniquePrefixedKeysIndexTest extends SchemaUniquePrefixedKeysIndexTestBase { From d45cca8b610e312e45b44dbeed9b9a38823da8a5 Mon Sep 17 00:00:00 2001 From: mondrake Date: Sun, 18 Jun 2023 19:57:05 +0200 Subject: [PATCH 09/13] II --- src/Driver/Database/dbal/Connection.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Driver/Database/dbal/Connection.php b/src/Driver/Database/dbal/Connection.php index c3019e76..7bb65410 100644 --- a/src/Driver/Database/dbal/Connection.php +++ b/src/Driver/Database/dbal/Connection.php @@ -692,4 +692,12 @@ public function expandArrayParameters(string $sql, array $params, array $types): $visitor->getTypes(), ]; } + + public function query($query, array $args = [], $options = []) { + if ($this->dbalExtension->getDebugging()) { + dump([$query, $args]); + } + return parent::query($query, $args, $options); + } + } From d87d3ee3cc1a70eb9c25515e68e79ac23ab4ef53 Mon Sep 17 00:00:00 2001 From: mondrake Date: Sun, 18 Jun 2023 21:27:45 +0200 Subject: [PATCH 10/13] III --- .../Database/dbal/DbalExtension/AbstractExtension.php | 2 +- .../Database/dbal/DbalExtension/AbstractMySqlExtension.php | 2 +- .../Database/dbal/DbalExtension/DbalExtensionInterface.php | 5 ++++- src/Driver/Database/dbal/DbalExtension/Oci8Extension.php | 2 +- .../Database/dbal/DbalExtension/PDOSqliteExtension.php | 3 ++- src/Driver/Database/dbal/Schema.php | 7 ++++--- 6 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/Driver/Database/dbal/DbalExtension/AbstractExtension.php b/src/Driver/Database/dbal/DbalExtension/AbstractExtension.php index 89f2f1b5..727442ca 100644 --- a/src/Driver/Database/dbal/DbalExtension/AbstractExtension.php +++ b/src/Driver/Database/dbal/DbalExtension/AbstractExtension.php @@ -589,7 +589,7 @@ public function delegateDropField(bool &$delegatedResult, DbalSchema $dbal_schem /** * {@inheritdoc} */ - public function delegateChangeField(&$primary_key_processed_by_extension, DbalSchema $dbal_schema, $drupal_table_name, $field_name, $field_new_name, array $drupal_field_new_specs, array $keys_new_specs, array $dbal_column_options) { + public function delegateChangeField(bool &$primary_key_processed_by_extension, bool &$indexes_processed_by_extension, DbalSchema $dbal_schema, string $drupal_table_name, string $field_name, string $field_new_name, array $drupal_field_new_specs, array $keys_new_specs, array $dbal_column_options) { throw new \LogicException("Method " . __METHOD__ . " not implemented."); } diff --git a/src/Driver/Database/dbal/DbalExtension/AbstractMySqlExtension.php b/src/Driver/Database/dbal/DbalExtension/AbstractMySqlExtension.php index 60da837d..2a0462e6 100644 --- a/src/Driver/Database/dbal/DbalExtension/AbstractMySqlExtension.php +++ b/src/Driver/Database/dbal/DbalExtension/AbstractMySqlExtension.php @@ -643,7 +643,7 @@ public function delegateAddField(&$primary_key_processed_by_extension, DbalSchem /** * {@inheritdoc} */ - public function delegateChangeField(&$primary_key_processed_by_extension, DbalSchema $dbal_schema, $drupal_table_name, $field_name, $field_new_name, array $drupal_field_new_specs, array $keys_new_specs, array $dbal_column_options) { + public function delegateChangeField(bool &$primary_key_processed_by_extension, bool &$indexes_processed_by_extension, DbalSchema $dbal_schema, string $drupal_table_name, string $field_name, string $field_new_name, array $drupal_field_new_specs, array $keys_new_specs, array $dbal_column_options) { $sql = 'ALTER TABLE {' . $drupal_table_name . '} CHANGE `' . $field_name . '` `' . $field_new_name . '` ' . $dbal_column_options['columnDefinition']; if (!empty($keys_new_specs['primary key'])) { $keys_sql = $this->createKeysSql(['primary key' => $keys_new_specs['primary key']]); diff --git a/src/Driver/Database/dbal/DbalExtension/DbalExtensionInterface.php b/src/Driver/Database/dbal/DbalExtension/DbalExtensionInterface.php index 56f9d40d..4048deb9 100644 --- a/src/Driver/Database/dbal/DbalExtension/DbalExtensionInterface.php +++ b/src/Driver/Database/dbal/DbalExtension/DbalExtensionInterface.php @@ -892,6 +892,9 @@ public function delegateDropField(bool &$delegatedResult, DbalSchema $dbal_schem * @param bool $primary_key_processed_by_extension * Passed by reference. TRUE if the extension also processed adding the * primary key for the table, FALSE otherwise. + * @param bool $indexes_processed_by_extension + * Passed by reference. TRUE if the extension also processed adding the + * indexes for the table, FALSE otherwise. * @param \Doctrine\DBAL\Schema\Schema $dbal_schema * The DBAL schema object. * @param string $drupal_table_name @@ -914,7 +917,7 @@ public function delegateDropField(bool &$delegatedResult, DbalSchema $dbal_schem * TRUE if the extension changed the field, FALSE if it has to be handled * by DBAL. */ - public function delegateChangeField(&$primary_key_processed_by_extension, DbalSchema $dbal_schema, $drupal_table_name, $field_name, $field_new_name, array $drupal_field_new_specs, array $keys_new_specs, array $dbal_column_options); + public function delegateChangeField(bool &$primary_key_processed_by_extension, bool &$indexes_processed_by_extension, DbalSchema $dbal_schema, string $drupal_table_name, string $field_name, string $field_new_name, array $drupal_field_new_specs, array $keys_new_specs, array $dbal_column_options); /** * Checks if an index exists. diff --git a/src/Driver/Database/dbal/DbalExtension/Oci8Extension.php b/src/Driver/Database/dbal/DbalExtension/Oci8Extension.php index 879dce51..efc3b25c 100644 --- a/src/Driver/Database/dbal/DbalExtension/Oci8Extension.php +++ b/src/Driver/Database/dbal/DbalExtension/Oci8Extension.php @@ -892,7 +892,7 @@ public function initAddedField(string $drupal_table_name, string $drupal_field_n /** * {@inheritdoc} */ - public function delegateChangeField(&$primary_key_processed_by_extension, DbalSchema $dbal_schema, $drupal_table_name, $field_name, $field_new_name, array $drupal_field_new_specs, array $keys_new_specs, array $dbal_column_options) { + public function delegateChangeField(bool &$primary_key_processed_by_extension, bool &$indexes_processed_by_extension, DbalSchema $dbal_schema, string $drupal_table_name, string $field_name, string $field_new_name, array $drupal_field_new_specs, array $keys_new_specs, array $dbal_column_options) { $primary_key_processed_by_extension = TRUE; $unquoted_db_table = $this->connection->getPrefixedTableName($drupal_table_name, FALSE); diff --git a/src/Driver/Database/dbal/DbalExtension/PDOSqliteExtension.php b/src/Driver/Database/dbal/DbalExtension/PDOSqliteExtension.php index d0e82bee..1c54e3fe 100644 --- a/src/Driver/Database/dbal/DbalExtension/PDOSqliteExtension.php +++ b/src/Driver/Database/dbal/DbalExtension/PDOSqliteExtension.php @@ -898,7 +898,7 @@ public function delegateDropField(bool &$delegatedResult, DbalSchema $dbal_schem /** * {@inheritdoc} */ - public function delegateChangeField(&$primary_key_processed_by_extension, DbalSchema $dbal_schema, $drupal_table_name, $field_name, $field_new_name, array $drupal_field_new_specs, array $keys_new_specs, array $dbal_column_options) { + public function delegateChangeField(bool &$primary_key_processed_by_extension, bool &$indexes_processed_by_extension, DbalSchema $dbal_schema, string $drupal_table_name, string $field_name, string $field_new_name, array $drupal_field_new_specs, array $keys_new_specs, array $dbal_column_options) { $old_schema = $this->buildTableSpecFromDbalSchema($dbal_schema, $drupal_table_name); $new_schema = $old_schema; @@ -934,6 +934,7 @@ public function delegateChangeField(&$primary_key_processed_by_extension, DbalSc $this->alterTable($drupal_table_name, $old_schema, $new_schema, $mapping); $primary_key_processed_by_extension = TRUE; + $indexes_processed_by_extension = TRUE; return TRUE; } diff --git a/src/Driver/Database/dbal/Schema.php b/src/Driver/Database/dbal/Schema.php index 2b5408a3..1c029105 100644 --- a/src/Driver/Database/dbal/Schema.php +++ b/src/Driver/Database/dbal/Schema.php @@ -718,7 +718,8 @@ public function changeField($table, $field, $field_new, $spec, $keys_new = []) { // fallback to platform specific syntax. // @see https://github.com/doctrine/dbal/issues/1033 $primary_key_processed_by_extension = FALSE; - if (!$this->dbalExtension->delegateChangeField($primary_key_processed_by_extension, $this->dbalSchema(), $table, $field, $field_new, $spec, $keys_new, $dbal_column_options)) { + $indexes_processed_by_extension = FALSE; + if (!$this->dbalExtension->delegateChangeField($primary_key_processed_by_extension, $indexes_processed_by_extension, $this->dbalSchema(), $table, $field, $field_new, $spec, $keys_new, $dbal_column_options)) { return; } // We need to reload the schema at next get. @@ -732,14 +733,14 @@ public function changeField($table, $field, $field_new, $spec, $keys_new = []) { } // Add unique keys. - if (!empty($keys_new['unique keys'])) { + if (!empty($keys_new['unique keys']) && !$indexes_processed_by_extension) { foreach ($keys_new['unique keys'] as $key => $fields) { $this->addUniqueKey($table, $key, $fields); } } // Add indexes. - if (!empty($keys_new['indexes'])) { + if (!empty($keys_new['indexes']) && !$indexes_processed_by_extension) { foreach ($keys_new['indexes'] as $index => $fields) { $this->addIndex($table, $index, $fields, $keys_new); } From e8240242b3395d6ecf23adcdee2db0dc3ed59924 Mon Sep 17 00:00:00 2001 From: mondrake Date: Sun, 18 Jun 2023 21:39:41 +0200 Subject: [PATCH 11/13] V --- src/Driver/Database/dbal/DbalExtension/AbstractExtension.php | 2 +- src/Driver/Database/dbal/Schema.php | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Driver/Database/dbal/DbalExtension/AbstractExtension.php b/src/Driver/Database/dbal/DbalExtension/AbstractExtension.php index 727442ca..752ec474 100644 --- a/src/Driver/Database/dbal/DbalExtension/AbstractExtension.php +++ b/src/Driver/Database/dbal/DbalExtension/AbstractExtension.php @@ -26,7 +26,7 @@ class AbstractExtension implements DbalExtensionInterface { /** * Enables debugging. */ - protected static bool $isDebugging = TRUE; + protected static bool $isDebugging = FALSE; /** * Constructs a DBAL extension object. diff --git a/src/Driver/Database/dbal/Schema.php b/src/Driver/Database/dbal/Schema.php index 1c029105..425c0920 100644 --- a/src/Driver/Database/dbal/Schema.php +++ b/src/Driver/Database/dbal/Schema.php @@ -357,6 +357,7 @@ public function dropTable($table) { * {@inheritdoc} */ public function addField($table, $field, $spec, $keys_new = []) { +$this->dbalExtension->setDebugging(TRUE); if (!$this->tableExists($table)) { throw new SchemaObjectDoesNotExistException(t("Cannot add field @table.@field: table doesn't exist.", ['@field' => $field, '@table' => $table])); } @@ -430,6 +431,7 @@ public function addField($table, $field, $spec, $keys_new = []) { $spec['not null'] = TRUE; $this->changeField($table, $field, $field, $spec); } +$this->dbalExtension->setDebugging(FALSE); } /** From f868647e7578175b062b2d73ce55a7ad7de98609 Mon Sep 17 00:00:00 2001 From: mondrake Date: Tue, 20 Jun 2023 16:11:16 +0200 Subject: [PATCH 12/13] A --- .../Database/dbal/DbalExtension/AbstractExtension.php | 2 +- .../Database/dbal/DbalExtension/AbstractMySqlExtension.php | 2 +- .../Database/dbal/DbalExtension/DbalExtensionInterface.php | 5 ++++- src/Driver/Database/dbal/DbalExtension/Oci8Extension.php | 2 +- .../Database/dbal/DbalExtension/PDOSqliteExtension.php | 3 ++- src/Driver/Database/dbal/Schema.php | 7 ++++--- 6 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/Driver/Database/dbal/DbalExtension/AbstractExtension.php b/src/Driver/Database/dbal/DbalExtension/AbstractExtension.php index 752ec474..b1323362 100644 --- a/src/Driver/Database/dbal/DbalExtension/AbstractExtension.php +++ b/src/Driver/Database/dbal/DbalExtension/AbstractExtension.php @@ -551,7 +551,7 @@ public function postDropTable(DbalSchema $dbal_schema, string $drupal_table_name /** * {@inheritdoc} */ - public function delegateAddField(&$primary_key_processed_by_extension, DbalSchema $dbal_schema, $drupal_table_name, $field_name, array $drupal_field_specs, array $keys_new_specs, array $dbal_column_options) { + public function delegateAddField(bool &$primary_key_processed_by_extension, bool &$indexes_processed_by_extension, DbalSchema $dbal_schema, string $drupal_table_name, string $field_name, array $drupal_field_specs, array $keys_new_specs, array $dbal_column_options) { return FALSE; } diff --git a/src/Driver/Database/dbal/DbalExtension/AbstractMySqlExtension.php b/src/Driver/Database/dbal/DbalExtension/AbstractMySqlExtension.php index 2a0462e6..697173e7 100644 --- a/src/Driver/Database/dbal/DbalExtension/AbstractMySqlExtension.php +++ b/src/Driver/Database/dbal/DbalExtension/AbstractMySqlExtension.php @@ -628,7 +628,7 @@ public function alterDbalColumnDefinition($context, &$dbal_column_definition, ar /** * {@inheritdoc} */ - public function delegateAddField(&$primary_key_processed_by_extension, DbalSchema $dbal_schema, $drupal_table_name, $field_name, array $drupal_field_specs, array $keys_new_specs, array $dbal_column_options) { + public function delegateAddField(bool &$primary_key_processed_by_extension, bool &$indexes_processed_by_extension, DbalSchema $dbal_schema, string $drupal_table_name, string $field_name, array $drupal_field_specs, array $keys_new_specs, array $dbal_column_options) { if (!empty($keys_new_specs['primary key']) && isset($drupal_field_specs['type']) && $drupal_field_specs['type'] == 'serial') { $sql = 'ALTER TABLE {' . $drupal_table_name . '} ADD `' . $field_name . '` ' . $dbal_column_options['columnDefinition']; $keys_sql = $this->createKeysSql(['primary key' => $keys_new_specs['primary key']]); diff --git a/src/Driver/Database/dbal/DbalExtension/DbalExtensionInterface.php b/src/Driver/Database/dbal/DbalExtension/DbalExtensionInterface.php index 4048deb9..7378db10 100644 --- a/src/Driver/Database/dbal/DbalExtension/DbalExtensionInterface.php +++ b/src/Driver/Database/dbal/DbalExtension/DbalExtensionInterface.php @@ -833,6 +833,9 @@ public function postDropTable(DbalSchema $dbal_schema, string $drupal_table_name * @param bool $primary_key_processed_by_extension * Passed by reference. TRUE if the extension also processed adding the * primary key for the table, FALSE otherwise. + * @param bool $indexes_processed_by_extension + * Passed by reference. TRUE if the extension also processed adding the + * indexes for the table, FALSE otherwise. * @param \Doctrine\DBAL\Schema\Schema $dbal_schema * The DBAL schema object. * @param string $drupal_table_name @@ -854,7 +857,7 @@ public function postDropTable(DbalSchema $dbal_schema, string $drupal_table_name * TRUE if the extension added the field, FALSE if it has to be handled * by DBAL. */ - public function delegateAddField(&$primary_key_processed_by_extension, DbalSchema $dbal_schema, $drupal_table_name, $field_name, array $drupal_field_specs, array $keys_new_specs, array $dbal_column_options); + public function delegateAddField(bool &$primary_key_processed_by_extension, bool &$indexes_processed_by_extension, DbalSchema $dbal_schema, string $drupal_table_name, string $field_name, array $drupal_field_specs, array $keys_new_specs, array $dbal_column_options); /** * Initializes a field newly added to a table. diff --git a/src/Driver/Database/dbal/DbalExtension/Oci8Extension.php b/src/Driver/Database/dbal/DbalExtension/Oci8Extension.php index efc3b25c..03f31a7c 100644 --- a/src/Driver/Database/dbal/DbalExtension/Oci8Extension.php +++ b/src/Driver/Database/dbal/DbalExtension/Oci8Extension.php @@ -810,7 +810,7 @@ public function alterDbalColumnDefinition($context, &$dbal_column_definition, ar /** * {@inheritdoc} */ - public function delegateAddField(&$primary_key_processed_by_extension, DbalSchema $dbal_schema, $drupal_table_name, $field_name, array $drupal_field_specs, array $keys_new_specs, array $dbal_column_options) { + public function delegateAddField(bool &$primary_key_processed_by_extension, bool &$indexes_processed_by_extension, DbalSchema $dbal_schema, string $drupal_table_name, string $field_name, array $drupal_field_specs, array $keys_new_specs, array $dbal_column_options) { $primary_key_processed_by_extension = TRUE; $unquoted_db_table = $this->connection->getPrefixedTableName($drupal_table_name, FALSE); diff --git a/src/Driver/Database/dbal/DbalExtension/PDOSqliteExtension.php b/src/Driver/Database/dbal/DbalExtension/PDOSqliteExtension.php index 1c54e3fe..5ad7034f 100644 --- a/src/Driver/Database/dbal/DbalExtension/PDOSqliteExtension.php +++ b/src/Driver/Database/dbal/DbalExtension/PDOSqliteExtension.php @@ -812,7 +812,7 @@ public function postDropTable(DbalSchema $dbal_schema, string $drupal_table_name /** * {@inheritdoc} */ - public function delegateAddField(&$primary_key_processed_by_extension, DbalSchema $dbal_schema, $drupal_table_name, $field_name, array $drupal_field_specs, array $keys_new_specs, array $dbal_column_options) { + public function delegateAddField(bool &$primary_key_processed_by_extension, bool &$indexes_processed_by_extension, DbalSchema $dbal_schema, string $drupal_table_name, string $field_name, array $drupal_field_specs, array $keys_new_specs, array $dbal_column_options) { // SQLite doesn't have a full-featured ALTER TABLE statement. It only // supports adding new fields to a table, in some simple cases. In most // cases, we have to create a new table and copy the data over. @@ -859,6 +859,7 @@ public function delegateAddField(&$primary_key_processed_by_extension, DbalSchem } } $this->alterTable($drupal_table_name, $old_schema, $new_schema, $mapping); + $indexes_processed_by_extension = TRUE; } return TRUE; } diff --git a/src/Driver/Database/dbal/Schema.php b/src/Driver/Database/dbal/Schema.php index 425c0920..4d25447c 100644 --- a/src/Driver/Database/dbal/Schema.php +++ b/src/Driver/Database/dbal/Schema.php @@ -391,9 +391,10 @@ public function addField($table, $field, $spec, $keys_new = []) { // Delegate to DBAL extension. $primary_key_processed_by_extension = FALSE; + $indexes_processed_by_extension = FALSE; $dbal_type = $this->getDbalColumnType($spec); $dbal_column_options = $this->getDbalColumnOptions('addField', $field, $dbal_type, $spec); - if ($this->dbalExtension->delegateAddField($primary_key_processed_by_extension, $this->dbalSchema(), $table, $field, $spec, $keys_new, $dbal_column_options)) { + if ($this->dbalExtension->delegateAddField($primary_key_processed_by_extension, $indexes_processed_by_extension, $this->dbalSchema(), $table, $field, $spec, $keys_new, $dbal_column_options)) { $this->dbalSchemaForceReload(); } else { @@ -411,14 +412,14 @@ public function addField($table, $field, $spec, $keys_new = []) { } // Add unique keys. - if (!empty($keys_new['unique keys'])) { + if (!empty($keys_new['unique keys']) && !$indexes_processed_by_extension) { foreach ($keys_new['unique keys'] as $key => $fields) { $this->addUniqueKey($table, $key, $fields); } } // Add indexes. - if (!empty($keys_new['indexes'])) { + if (!empty($keys_new['indexes']) && !$indexes_processed_by_extension) { foreach ($keys_new['indexes'] as $index => $fields) { $this->addIndex($table, $index, $fields, $keys_new); } From bf8d8e9ddfd61048e926da1c6ee185713aa602cd Mon Sep 17 00:00:00 2001 From: mondrake Date: Tue, 20 Jun 2023 16:16:36 +0200 Subject: [PATCH 13/13] B --- .github/workflows/pr.yml | 3 +-- src/Driver/Database/dbal/Schema.php | 2 -- tests/src/Kernel/dbal/SchemaUniquePrefixedKeysIndexTest.php | 2 +- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index bba7dda8..cda934ef 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -33,8 +33,7 @@ jobs: # - "8.1" - "8.2" test-args: - - "--group Databasexx" -# - "--group Database" + - "--group Database" # - "--group Entity" # - "--group Cache,Config" # - "--group field,Field" diff --git a/src/Driver/Database/dbal/Schema.php b/src/Driver/Database/dbal/Schema.php index 4d25447c..2e9ae7e2 100644 --- a/src/Driver/Database/dbal/Schema.php +++ b/src/Driver/Database/dbal/Schema.php @@ -357,7 +357,6 @@ public function dropTable($table) { * {@inheritdoc} */ public function addField($table, $field, $spec, $keys_new = []) { -$this->dbalExtension->setDebugging(TRUE); if (!$this->tableExists($table)) { throw new SchemaObjectDoesNotExistException(t("Cannot add field @table.@field: table doesn't exist.", ['@field' => $field, '@table' => $table])); } @@ -432,7 +431,6 @@ public function addField($table, $field, $spec, $keys_new = []) { $spec['not null'] = TRUE; $this->changeField($table, $field, $field, $spec); } -$this->dbalExtension->setDebugging(FALSE); } /** diff --git a/tests/src/Kernel/dbal/SchemaUniquePrefixedKeysIndexTest.php b/tests/src/Kernel/dbal/SchemaUniquePrefixedKeysIndexTest.php index b4b83922..995f3eb1 100644 --- a/tests/src/Kernel/dbal/SchemaUniquePrefixedKeysIndexTest.php +++ b/tests/src/Kernel/dbal/SchemaUniquePrefixedKeysIndexTest.php @@ -7,7 +7,7 @@ /** * Tests adding UNIQUE keys to tables. * - * @group Databasexx + * @group Database */ class SchemaUniquePrefixedKeysIndexTest extends SchemaUniquePrefixedKeysIndexTestBase {