From 0a332a303dac1c612f83ba4e06bcb1c5c36df948 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Fri, 21 Jun 2024 19:41:57 +1000 Subject: [PATCH 1/8] mariadb: add nightly workflow to facilitate mariadb "nightlies" (#6435) | Q | A |------------- | ----------- | Type | improvement | Fixed issues | #6433 #### Summary Nightly cron scheduled alternate to #6433. --- .github/workflows/nightly.yml | 72 +++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 .github/workflows/nightly.yml diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml new file mode 100644 index 00000000000..99799afcb7d --- /dev/null +++ b/.github/workflows/nightly.yml @@ -0,0 +1,72 @@ +name: "Continuous Integration (Nightly)" + +on: + schedule: + - cron: "12 3 * * *" + +env: + fail-fast: true + +jobs: + phpunit-mariadb: + name: "PHPUnit with MariaDB" + runs-on: "ubuntu-24.04" + + strategy: + matrix: + php-version: + - "7.4" + - "8.3" + mariadb-version: + - "earliest" + - "verylatest" + extension: + - "mysqli" + - "pdo_mysql" + + services: + mariadb: + image: "quay.io/mariadb-foundation/mariadb-devel:${{ matrix.mariadb-version }}" + env: + MARIADB_ALLOW_EMPTY_ROOT_PASSWORD: yes + MARIADB_DATABASE: "doctrine_tests" + + options: >- + --health-cmd "healthcheck.sh --connect --innodb_initialized" + + ports: + - "3306:3306" + + steps: + - name: "Checkout" + uses: "actions/checkout@v4" + with: + fetch-depth: 2 + + - name: "Install PHP" + uses: "shivammathur/setup-php@v2" + with: + php-version: "${{ matrix.php-version }}" + coverage: "pcov" + ini-values: "zend.assertions=1" + extensions: "${{ matrix.extension }}" + + - name: "Install dependencies with Composer" + uses: "ramsey/composer-install@v3" + with: + composer-options: "--ignore-platform-req=php+" + + - name: "Run PHPUnit" + run: "vendor/bin/phpunit -c ci/github/phpunit/${{ matrix.extension }}.xml" + + - name: Tell the MariaDB Folks if it failed + if: ${{ failure() }} + uses: zulip/github-actions-zulip/send-message@v1 + with: + api-key: ${{ secrets.MARIADB_ZULIP_API_KEY }} + email: "doctrine-bot@mariadb.zulipchat.com" + organization-url: "https://mariadb.zulipchat.com" + to: "Buildbot" + type: "stream" + topic: "CI - Doctrine/DBAL" + content: "There was an error running Doctrine on MariaDB:${{ matrix.mariadb-version }} - URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}." From 4dad03988a55298d59e4784cc9ac898b09ddb730 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Sat, 22 Jun 2024 17:59:53 +1000 Subject: [PATCH 2/8] ci: nightly - php-8.1 min version (#6457) --- .github/workflows/nightly.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 99799afcb7d..4c9d92ab390 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -15,7 +15,7 @@ jobs: strategy: matrix: php-version: - - "7.4" + - "8.1" - "8.3" mariadb-version: - "earliest" From cdcfc22822b9d17e4fa7a99eda68d19ec85c061e Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Sat, 22 Jun 2024 18:18:47 +1000 Subject: [PATCH 3/8] ci: nightly - php-8.1 only + workflow_dispatch --- .github/workflows/nightly.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 4c9d92ab390..92841c15734 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -3,6 +3,7 @@ name: "Continuous Integration (Nightly)" on: schedule: - cron: "12 3 * * *" + workflow_dispatch: env: fail-fast: true @@ -15,7 +16,6 @@ jobs: strategy: matrix: php-version: - - "8.1" - "8.3" mariadb-version: - "earliest" From 90424473eb144659a89fb1b5c9bca37297085351 Mon Sep 17 00:00:00 2001 From: Jan Nedbal Date: Mon, 24 Jun 2024 20:44:54 +0200 Subject: [PATCH 4/8] Docs: update custom platform example to use middlewares (#6460) Old approach no longer works in DBAL 4 Closes https://github.com/doctrine/dbal/issues/6354, closes https://github.com/doctrine/dbal/issues/6459 --- docs/en/reference/platforms.rst | 34 +++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/docs/en/reference/platforms.rst b/docs/en/reference/platforms.rst index 5d7477c44a3..1c934cb6263 100644 --- a/docs/en/reference/platforms.rst +++ b/docs/en/reference/platforms.rst @@ -74,20 +74,34 @@ database vendor and version best. Otherwise it is not guaranteed that the compatibility in terms of SQL dialect and feature support between Doctrine DBAL and the database server will always be given. -If you want to overwrite parts of your platform you can do so when -creating a connection. There is a ``platform`` option you can pass -an instance of the platform you want the connection to use: +If you want to overwrite parts of your platform you can do so by +using a middleware: :: 'pdo_sqlite', - 'path' => 'database.sqlite', - 'platform' => $myPlatform, - ]; - $conn = DriverManager::getConnection($options); + class CustomSQLitePlatform extends SqlitePlatform {} + + class CustomDriver extends AbstractDriverMiddleware + { + public function getDatabasePlatform(ServerVersionProvider $versionProvider) + { + return new CustomSQLitePlatform(); + } + } + + class CustomMiddleware implements Driver\Middleware + { + public function wrap(Driver $driver): Driver + { + return new CustomDriver($driver); + } + } + + $config = new Doctrine\DBAL\Configuration(); + $config->setMiddlewares([new CustomMiddleware()]); + + $connection = DriverManager::getConnection($params, $config); This way you can optimize your schema or generated SQL code with features that might not be portable for instance, however are From d3959ed0995d37dc28bf1587d48f259376c4df3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Tue, 2 Jul 2024 21:13:30 +0200 Subject: [PATCH 5/8] Complete sentence I asked internally how it is supposed to end, and got the answer straight from the horse's mouth. --- src/Schema/AbstractAsset.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Schema/AbstractAsset.php b/src/Schema/AbstractAsset.php index ab8fdec0303..6934133ffb9 100644 --- a/src/Schema/AbstractAsset.php +++ b/src/Schema/AbstractAsset.php @@ -20,7 +20,8 @@ * The abstract asset allows to reset the name of all assets without publishing this to the public userland. * * This encapsulation hack is necessary to keep a consistent state of the database schema. Say we have a list of tables - * array($tableName => Table($tableName)); if you want to rename the table, you have to make sure + * array($tableName => Table($tableName)); if you want to rename the table, you have to make sure this does not get + * recreated during schema migration. */ abstract class AbstractAsset { From 2fe737f19309b4b0aac886935e8af6d1f9123b26 Mon Sep 17 00:00:00 2001 From: PrinsFrank <25006490+PrinsFrank@users.noreply.github.com> Date: Tue, 16 Jul 2024 09:27:58 +0200 Subject: [PATCH 6/8] Fix update/delete aliases in documentation (#6470) | Q | A |------------- | ----------- | Type | bug/improvement | Fixed issues | Incorrect & inconsistent QueryBuilder documentation for aliases in update/delete #### Summary In #6394 the documentation was partially updated to remove aliases for the documentation for the update method, as the separate parameter for it was removed in the upgrade from 3.x to 4.x. Inline aliasing is still possible, and I suspect this was the reason the extra parameter was removed. ( `->update('users alias1', 'alias2')`)? This PR readds the alias to the documentation for the occurences in the linked PR, and also updates the other occurences in docblocks + the online documentation. --- docs/en/reference/query-builder.rst | 2 +- src/Query/QueryBuilder.php | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/en/reference/query-builder.rst b/docs/en/reference/query-builder.rst index b15a75f67ac..ecfb5337663 100644 --- a/docs/en/reference/query-builder.rst +++ b/docs/en/reference/query-builder.rst @@ -309,7 +309,7 @@ user-input: update('users', 'u') + ->update('users u') ->set('u.logins', 'u.logins + 1') ->set('u.last_login', '?') ->setParameter(0, $userInputLastLogin) diff --git a/src/Query/QueryBuilder.php b/src/Query/QueryBuilder.php index 9f4eb5a30a4..c6d33448ab3 100644 --- a/src/Query/QueryBuilder.php +++ b/src/Query/QueryBuilder.php @@ -580,8 +580,8 @@ public function addSelect(string $expression, string ...$expressions): self * * * $qb = $conn->createQueryBuilder() - * ->delete('users') - * ->where('users.id = :user_id') + * ->delete('users u') + * ->where('u.id = :user_id') * ->setParameter(':user_id', 1); * * @@ -606,9 +606,9 @@ public function delete(string $table): self * * * $qb = $conn->createQueryBuilder() - * ->update('counters') - * ->set('counters.value', 'counters.value + 1') - * ->where('counters.id = ?'); + * ->update('counters c') + * ->set('c.value', 'c.value + 1') + * ->where('c.id = ?'); * * * @param string $table The table whose rows are subject to the update. @@ -785,7 +785,7 @@ public function rightJoin(string $fromAlias, string $join, string $alias, ?strin * * * $qb = $conn->createQueryBuilder() - * ->update('counters', 'c') + * ->update('counters c') * ->set('c.value', 'c.value + 1') * ->where('c.id = ?'); * @@ -821,7 +821,7 @@ public function set(string $key, string $value): self * $or->add($qb->expr()->eq('c.id', 1)); * $or->add($qb->expr()->eq('c.id', 2)); * - * $qb->update('counters', 'c') + * $qb->update('counters c') * ->set('c.value', 'c.value + 1') * ->where($or); * From b35648d64d9b641ee20f74b29f01a894e38027b6 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Tue, 16 Jul 2024 12:45:52 +0200 Subject: [PATCH 7/8] CI: Add MySQL 9, reduce test matrix (#6462) MySQL 9 has been released and 8.4 has been declared to be the LTS release. I've added MySQL 9 to the test matrix and took the opportunity to shrink the test matrix a little. Our CI is othen blocked because of too many concurrent jobs, so we might not want to test all possible permutations of PHP and MySQL versions. Taking into account that we're going to maintain the 3.x branch for a little longer, we need a strategy for not letting the test matrix grow exponentially with every future PHP or DBMS release. My proposal for MySQL: * Test all supported MySQL versions (currently: 5.7, 8.0, 8.4, 9.0) with the latest PHP version (currently 8.3). * Test the oldest supported PHP release (currently 7.4) against one release only (MySQL 8.0) only. All other PHP releases are tested against SQLite already. If this proposal is accepted, I'd like to work out a similar strategy for the other supported DBMS. I think we should also document that strategy properly then. --- .github/workflows/continuous-integration.yml | 35 ++++--------------- .../Driver/VersionAwarePlatformDriverTest.php | 2 ++ 2 files changed, 8 insertions(+), 29 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index fcb77758984..ac1a1101fc7 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -378,57 +378,34 @@ jobs: strategy: matrix: php-version: - - "7.4" - - "8.1" + - "8.3" mysql-version: - "5.7" - "8.0" + - "9.0" extension: - "mysqli" - "pdo_mysql" config-file-suffix: - "" include: - - mysql-version: "8.0" - # https://stackoverflow.com/questions/60902904/how-to-pass-mysql-native-password-to-mysql-service-in-github-actions - custom-entrypoint: >- - --entrypoint sh mysql:8.0 -c "exec docker-entrypoint.sh mysqld --default-authentication-plugin=mysql_native_password" - config-file-suffix: "-tls" php-version: "7.4" mysql-version: "8.0" extension: "mysqli" - - php-version: "8.2" + - php-version: "7.4" mysql-version: "8.0" extension: "mysqli" - custom-entrypoint: >- - --entrypoint sh mysql:8.0 -c "exec docker-entrypoint.sh mysqld --default-authentication-plugin=mysql_native_password" - - php-version: "8.2" + - php-version: "7.4" mysql-version: "8.0" extension: "pdo_mysql" - custom-entrypoint: >- - --entrypoint sh mysql:8.0 -c "exec docker-entrypoint.sh mysqld --default-authentication-plugin=mysql_native_password" - - php-version: "8.3" - mysql-version: "8.0" - extension: "mysqli" + # Workaround for https://bugs.mysql.com/114876 - php-version: "8.3" - mysql-version: "8.0" - extension: "pdo_mysql" - - php-version: "7.4" mysql-version: "8.4" extension: "mysqli" custom-entrypoint: >- --entrypoint sh mysql:8.4 -c "exec docker-entrypoint.sh mysqld --mysql-native-password=ON" - - php-version: "7.4" - mysql-version: "8.4" - extension: "pdo_mysql" - custom-entrypoint: >- - --entrypoint sh mysql:8.4 -c "exec docker-entrypoint.sh mysqld --mysql-native-password=ON" - - php-version: "8.1" - mysql-version: "8.4" - extension: "mysqli" - custom-entrypoint: >- - --entrypoint sh mysql:8.4 -c "exec docker-entrypoint.sh mysqld --mysql-native-password=ON" - - php-version: "8.1" + - php-version: "8.3" mysql-version: "8.4" extension: "pdo_mysql" custom-entrypoint: >- diff --git a/tests/Driver/VersionAwarePlatformDriverTest.php b/tests/Driver/VersionAwarePlatformDriverTest.php index 8a84607f954..e329f76a37d 100644 --- a/tests/Driver/VersionAwarePlatformDriverTest.php +++ b/tests/Driver/VersionAwarePlatformDriverTest.php @@ -51,6 +51,8 @@ public static function mySQLVersionProvider(): array ['8', MySQL80Platform::class], ['8.0', MySQL80Platform::class], ['8.0.11', MySQL80Platform::class], + ['8.4.1', MySQL80Platform::class], + ['9.0.0', MySQL80Platform::class], ['6', MySQL57Platform::class], ['10.0.15-MariaDB-1~wheezy', MySQLPlatform::class], ['5.5.5-10.1.25-MariaDB', MySQLPlatform::class], From 349c83393c96260d6afcec6be7c30a0eacde0196 Mon Sep 17 00:00:00 2001 From: Matteo Beccati Date: Mon, 22 Jul 2024 12:16:06 +0200 Subject: [PATCH 8/8] Properly handle MySQL error code 4031 from PHP 8.4 (#6363) | Q | A |------------- | ----------- | Type | improvement | Fixed issues | Prevents future issues ;-) #### Summary PHP 8.4 will support a new error code 4031 in mysqlnd when the connection is dropped due to timeouts. It has been introduced in: https://github.com/mysql/mysql-server/commit/14508bbb1790697c28659dd051fbc855cd3b5da9 And PHP 8.4 will support it: https://github.com/php/php-src/pull/13618 The PR gets the test suite green again (mysqli + pdo_mysql). I have used 4.0.x as base, but feel free to change according to your preferences. --- src/Driver/API/MySQL/ExceptionConverter.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Driver/API/MySQL/ExceptionConverter.php b/src/Driver/API/MySQL/ExceptionConverter.php index 87d50aff9e3..fdfc75a77fd 100644 --- a/src/Driver/API/MySQL/ExceptionConverter.php +++ b/src/Driver/API/MySQL/ExceptionConverter.php @@ -101,6 +101,7 @@ public function convert(Exception $exception, ?Query $query): DriverException return new ConnectionException($exception, $query); case 2006: + case 4031: return new ConnectionLost($exception, $query); case 1048: