From dfe5ddc27b2a3a279fd9fee46615d3c097b1c18d Mon Sep 17 00:00:00 2001 From: Jan Lam Date: Tue, 13 Oct 2026 15:59:56 +0200 Subject: [PATCH 1/3] Drop doctrine/orm dependency --- .github/workflows/main.yaml | 11 +++++++---- bin/mysql_github.sh | 2 +- composer.json | 4 ++-- test/MysqlPersistentConnectionTest.php | 10 +++++----- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 1596c12..41dfa4c 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -12,10 +12,11 @@ jobs: strategy: matrix: - php-versions: ['7.3', '7.4', '8.0'] - name: PHP ${{ matrix.php-versions }} + php-versions: ['8.3', '8.4'] + dbal: ['3.*', '4.*'] + name: PHP ${{ matrix.php-versions }}, DBAL ${{ matrix.dbal }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php-versions }} @@ -29,7 +30,9 @@ jobs: key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} restore-keys: ${{ runner.os }}-composer- - name: composer install - run: composer install --no-progress --prefer-dist --optimize-autoloader + run: | + composer require --dev --no-update doctrine/dbal:"${{ matrix.dbal }}" + composer update doctrine/dbal --no-progress --prefer-dist --optimize-autoloader - run: sudo /etc/init.d/mysql start - name: phpunit run: php vendor/bin/phpunit diff --git a/bin/mysql_github.sh b/bin/mysql_github.sh index 027fff8..d12d7e3 100755 --- a/bin/mysql_github.sh +++ b/bin/mysql_github.sh @@ -15,7 +15,7 @@ finish() { DBNAME="$(date +%s%N)" echo "CREATE DATABASE \`$DBNAME\`;" | $MYSQL >&3 -# PHP 7.3 compatibility, does not support caching_sha2_password, use mysql_native_password on a new user instead. +# Older PHP/mysql clients do not support caching_sha2_password, use mysql_native_password on a new user instead. echo "CREATE USER IF NOT EXISTS 'test'@'localhost' IDENTIFIED WITH mysql_native_password BY 'test';" | $MYSQL >&3 echo "GRANT ALL PRIVILEGES ON *.* TO 'test'@'localhost';" | $MYSQL >&3 echo "FLUSH PRIVILEGES;" | $MYSQL >&3 diff --git a/composer.json b/composer.json index 2ee5659..16dde04 100644 --- a/composer.json +++ b/composer.json @@ -4,10 +4,10 @@ "description": "Provide a real database, safe for testing purposes", "license": "MIT", "require": { - "php": "^7.3|^8.0", - "doctrine/orm": "^2.5.4" + "php": "^8.3" }, "require-dev": { + "doctrine/dbal": "^3.7|^4.0", "hostnet/phpcs-tool": "^9.1.0", "phpunit/phpunit": "^9.4" }, diff --git a/test/MysqlPersistentConnectionTest.php b/test/MysqlPersistentConnectionTest.php index 3ce4668..e48139b 100644 --- a/test/MysqlPersistentConnectionTest.php +++ b/test/MysqlPersistentConnectionTest.php @@ -7,6 +7,7 @@ namespace Hostnet\Component\DatabaseTest; use Doctrine\DBAL\DriverManager; +use Doctrine\DBAL\Tools\DsnParser; use PHPUnit\Framework\TestCase; /** @@ -22,7 +23,7 @@ public function testConstruction(): void $connection = new MysqlPersistentConnection(); $url = $connection->getConnectionUrl(); - $this->assertCount(1, $this->listDatabases(['url' => $url])); + $this->assertCount(1, $this->listDatabases((new DsnParser(['mysql' => 'pdo_mysql']))->parse($url))); } /** @@ -55,13 +56,12 @@ public function testDestruction(): void * * @param string[] $params Doctrine connection parameters * @return string[] - * @throws \Doctrine\DBAL\DBALException + * @throws \Doctrine\DBAL\Exception */ private function listDatabases(array $params): array { - $doctrine = DriverManager::getConnection($params); - $statement = $doctrine->executeQuery('SHOW DATABASES'); - $data = $statement->fetchAll(\PDO::FETCH_COLUMN); + $doctrine = DriverManager::getConnection($params); + $data = $doctrine->executeQuery('SHOW DATABASES')->fetchFirstColumn(); return array_filter( $data, From 448bf7f710efa8e60d66c00a951ec0a4384b0097 Mon Sep 17 00:00:00 2001 From: Jan Lam Date: Tue, 13 Oct 2026 16:04:23 +0200 Subject: [PATCH 2/3] update .gitattributes --- .gitattributes | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitattributes b/.gitattributes index d41c778..d9f4a3b 100644 --- a/.gitattributes +++ b/.gitattributes @@ -3,3 +3,4 @@ .gitignore export-ignore /test export-ignore /phpunit.xml.dist export-ignore +/phpcs.xml.dist export-ignore From d973de0d58de5f8b28d9bbaaf3f90c59500147a5 Mon Sep 17 00:00:00 2001 From: Jan Lam Date: Tue, 13 Oct 2026 16:07:15 +0200 Subject: [PATCH 3/3] Support doctrine/dbal 3 and 4 on PHP 8.3+ Drop the unused doctrine/orm requirement and test against dbal ^3.7|^4.0. Run CI on PHP 8.3/8.4 against both DBAL majors. Co-Authored-By: Claude Sonnet 5.5 --- .github/workflows/main.yaml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 41dfa4c..2e7ae1a 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -27,12 +27,10 @@ jobs: - uses: actions/cache@v4 with: path: ${{ steps.composer-cache.outputs.dir }} - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} - restore-keys: ${{ runner.os }}-composer- + key: ${{ runner.os }}-composer-${{ matrix.dbal }}-${{ hashFiles('**/composer.json') }} + restore-keys: ${{ runner.os }}-composer-${{ matrix.dbal }}- - name: composer install - run: | - composer require --dev --no-update doctrine/dbal:"${{ matrix.dbal }}" - composer update doctrine/dbal --no-progress --prefer-dist --optimize-autoloader + run: composer require --dev doctrine/dbal:"${{ matrix.dbal }}" --no-progress --prefer-dist --optimize-autoloader - run: sudo /etc/init.d/mysql start - name: phpunit run: php vendor/bin/phpunit