From ff9d49c7635acdd601f52fde35dc1d08cea29a77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Fr=C3=A9mont?= Date: Mon, 24 Nov 2025 12:28:06 +0100 Subject: [PATCH 1/4] Add support for Symfony 8 --- .github/workflows/test-application.yaml | 15 ++++++++++++++- CHANGELOG.md | 6 ++++++ composer.json | 4 ++-- .../Tools/Console/InitDoctrineDbalCommandTest.php | 7 ++++++- 4 files changed, 28 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test-application.yaml b/.github/workflows/test-application.yaml index 1af57077..3c63fb3d 100644 --- a/.github/workflows/test-application.yaml +++ b/.github/workflows/test-application.yaml @@ -32,15 +32,24 @@ jobs: - sqlite dependencies: - highest + symfony-version: + - '*' include: - php-version: '8.0' dependencies: lowest + symfony-version: '*' db: sqlite - php-version: '8.0' dependencies: lowest + symfony-version: '5.*' db: mysql - php-version: '8.0' dependencies: lowest + symfony-version: '5.*' + db: pgsql + - php-version: '8.5' + dependencies: lowest + symfony-version: '8.*' db: pgsql services: @@ -73,13 +82,17 @@ jobs: with: php-version: ${{ matrix.php-version }} extensions: "pdo, pdo_sqlite, pdo_mysql, mysql, pdo_pgsql" - tools: 'composer:v2' + tools: 'composer:v2, flex' - name: PHP 8.0 simple cache # Symfony 5 is not compatible with SimpleCache 3 but does not declare a conflict. Symfony 6 can not be installed on PHP 8.0. if: ${{ '8.0' == matrix.php-version }} run: composer require psr/simple-cache "^2.0" --no-update + - name: Symfony version + if: matrix.symfony-version != '*' + run: composer config extra.symfony.require ${{ matrix.symfony-version }} + - name: Install dependencies with Composer uses: ramsey/composer-install@v2 with: diff --git a/CHANGELOG.md b/CHANGELOG.md index bad87269..9b6a0ee5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,12 @@ Changelog ========= +2.0.3 +----- + +* Allow installation with Symfony 8. +* Test with PHP 8.5. + 2.0.2 ----- diff --git a/composer.json b/composer.json index d8ad814f..dc45f2cb 100644 --- a/composer.json +++ b/composer.json @@ -34,8 +34,8 @@ "ext-simplexml": "*", "psr/log": "^1 || ^2 || ^3", "phpcr/phpcr-api-tests": "2.1.25", - "phpunit/phpunit": "^9.0", - "symfony/cache": "^5.4 || ^6.2 || ^7.0", + "phpunit/phpunit": "^9.6.16", + "symfony/cache": "^5.4 || ^6.2 || ^7.0 || ^8.0", "phpstan/phpstan": "^2.0" }, "autoload": { diff --git a/tests/Tools/Console/InitDoctrineDbalCommandTest.php b/tests/Tools/Console/InitDoctrineDbalCommandTest.php index bd1e9cff..7669e5f0 100644 --- a/tests/Tools/Console/InitDoctrineDbalCommandTest.php +++ b/tests/Tools/Console/InitDoctrineDbalCommandTest.php @@ -79,7 +79,12 @@ public function setUp(): void $this->application->setHelperSet($this->helperSet); $command = new InitDoctrineDbalCommand(); - $this->application->add($command); + + if (method_exists($this->application, 'addCommand')) { + $this->application->addCommand($command); + } else { + $this->application->add($command); + } } /** From f43864ba521e18a4e5e4d390629ad5f88289b8bf Mon Sep 17 00:00:00 2001 From: David Buchmann Date: Sat, 29 Nov 2025 14:13:30 +0100 Subject: [PATCH 2/4] remove deprecated xml_parser_free that was a noop since php 8.0 --- .../Transport/DoctrineDBAL/XmlParser/XmlToPropsParser.php | 3 --- .../Transport/DoctrineDBAL/XmlPropsRemover/XmlPropsRemover.php | 3 --- 2 files changed, 6 deletions(-) diff --git a/src/Jackalope/Transport/DoctrineDBAL/XmlParser/XmlToPropsParser.php b/src/Jackalope/Transport/DoctrineDBAL/XmlParser/XmlToPropsParser.php index 3710bbcf..18e90e72 100644 --- a/src/Jackalope/Transport/DoctrineDBAL/XmlParser/XmlToPropsParser.php +++ b/src/Jackalope/Transport/DoctrineDBAL/XmlParser/XmlToPropsParser.php @@ -60,9 +60,6 @@ public function parse(): \stdClass \xml_set_character_data_handler($parser, [$this, 'dataHandler']); \xml_parse($parser, $this->xml, true); - \xml_parser_free($parser); - // avoid memory leaks and unset the parser see: https://www.php.net/manual/de/function.xml-parser-free.php - unset($parser); return $this->data; } diff --git a/src/Jackalope/Transport/DoctrineDBAL/XmlPropsRemover/XmlPropsRemover.php b/src/Jackalope/Transport/DoctrineDBAL/XmlPropsRemover/XmlPropsRemover.php index 7ea09d6f..fa247917 100644 --- a/src/Jackalope/Transport/DoctrineDBAL/XmlPropsRemover/XmlPropsRemover.php +++ b/src/Jackalope/Transport/DoctrineDBAL/XmlPropsRemover/XmlPropsRemover.php @@ -75,9 +75,6 @@ public function removeProps(): array \xml_set_character_data_handler($parser, [$this, 'dataHandler']); \xml_parse($parser, $this->xml, true); - \xml_parser_free($parser); - // avoid memory leaks and unset the parser see: https://www.php.net/manual/de/function.xml-parser-free.php - unset($parser); return [ $this->newXml.PHP_EOL, From 7558e04584227d9e4a05e6856cfc0bafcf133738 Mon Sep 17 00:00:00 2001 From: David Buchmann Date: Sat, 29 Nov 2025 14:18:32 +0100 Subject: [PATCH 3/4] only call setAccessible in PHP 8.0 as afterwards it is no longer needed --- tests/Transport/DoctrineDBAL/CachedClientTest.php | 5 ++++- tests/Transport/DoctrineDBAL/ClientTest.php | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/Transport/DoctrineDBAL/CachedClientTest.php b/tests/Transport/DoctrineDBAL/CachedClientTest.php index 6860829b..c3ee8298 100644 --- a/tests/Transport/DoctrineDBAL/CachedClientTest.php +++ b/tests/Transport/DoctrineDBAL/CachedClientTest.php @@ -47,7 +47,10 @@ public function testDefaultKeySanitizer(): void $client = $this->getClient($this->getConnection()); $reflection = new \ReflectionClass($client); $keySanitizerProperty = $reflection->getProperty('keySanitizer'); - $keySanitizerProperty->setAccessible(true); + // remove when we drop PHP 8.0 support + if (PHP_VERSION_ID < 80100) { + $keySanitizerProperty->setAccessible(true); + } $defaultKeySanitizer = $keySanitizerProperty->getValue($client); $result = $defaultKeySanitizer(' :{}().@/"\\'); // not allowed PSR16 keys diff --git a/tests/Transport/DoctrineDBAL/ClientTest.php b/tests/Transport/DoctrineDBAL/ClientTest.php index 798e8492..3f7d8db4 100644 --- a/tests/Transport/DoctrineDBAL/ClientTest.php +++ b/tests/Transport/DoctrineDBAL/ClientTest.php @@ -341,7 +341,10 @@ public function testUuid(): void { $class = new \ReflectionClass(Client::class); $method = $class->getMethod('generateUuid'); - $method->setAccessible(true); + // remove when we drop PHP 8.0 support + if (PHP_VERSION_ID < 80100) { + $method->setAccessible(true); + } self::assertIsString($method->invoke($this->transport)); From 28938f0c221cd8f21403720157c0687fb028b11c Mon Sep 17 00:00:00 2001 From: David Buchmann Date: Sat, 29 Nov 2025 15:10:46 +0100 Subject: [PATCH 4/4] use pdo\sqlite::createFunction if available --- .../Transport/DoctrineDBAL/Client.php | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/Jackalope/Transport/DoctrineDBAL/Client.php b/src/Jackalope/Transport/DoctrineDBAL/Client.php index 3d817b2f..dc1462ac 100644 --- a/src/Jackalope/Transport/DoctrineDBAL/Client.php +++ b/src/Jackalope/Transport/DoctrineDBAL/Client.php @@ -166,7 +166,8 @@ public function __construct(FactoryInterface $factory, Connection $conn) */ private function registerSqliteFunctions(\PDO $sqliteConnection): void { - $sqliteConnection->sqliteCreateFunction( + $this->sqliteCreateFunction( + $sqliteConnection, 'EXTRACTVALUE', function ($string, $expression) { if (null === $string) { @@ -208,7 +209,8 @@ function ($string, $expression) { 2 ); - $sqliteConnection->sqliteCreateFunction( + $this->sqliteCreateFunction( + $sqliteConnection, 'CONCAT', function () { return implode('', func_get_args()); @@ -216,6 +218,20 @@ function () { ); } + /** + * BC hack for PHP < 8.4. After that version we always talk with a \Pdo\Sqlite object. + */ + private function sqliteCreateFunction(\PDO $sqliteConnection, string $name, callable $function, int $numArgs = -1): void + { + if (class_exists(\Pdo\Sqlite::class) && $sqliteConnection instanceof \Pdo\Sqlite) { + $sqliteConnection->createFunction($name, $function, $numArgs); + + return; + } + + $sqliteConnection->sqliteCreateFunction($name, $function, $numArgs); + } + public function getConnection(): Connection { $this->initConnection();