From d16b55557636f11905495181091aa6ea874d2e1d Mon Sep 17 00:00:00 2001 From: Jan Skrasek Date: Sat, 9 Nov 2024 18:25:35 +0100 Subject: [PATCH 1/5] build with PHP 8.4 --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 967bd1c..717b0c7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -24,7 +24,7 @@ jobs: strategy: matrix: - php-version: [ '8.1', '8.2', '8.3' ] + php-version: [ '8.1', '8.2', '8.3', '8.4' ] steps: - name: Checkout @@ -58,7 +58,7 @@ jobs: strategy: fail-fast: false matrix: - php-version: [ '8.1', '8.2', '8.3' ] + php-version: [ '8.1', '8.2', '8.3', '8.4' ] runs-on: ubuntu-latest From 1234d7757d1b19db3ab4674123ff6dd438ffc27f Mon Sep 17 00:00:00 2001 From: Jan Skrasek Date: Sat, 9 Nov 2024 18:30:03 +0100 Subject: [PATCH 2/5] fix nullability for PHP 8.4 --- src/Bridges/SymfonyBundle/DataCollector/QueryDataCollector.php | 2 +- src/Drivers/Exception/DriverException.php | 2 +- src/Drivers/Exception/QueryException.php | 2 +- src/Drivers/Exception/UnknownMysqlTimezoneException.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Bridges/SymfonyBundle/DataCollector/QueryDataCollector.php b/src/Bridges/SymfonyBundle/DataCollector/QueryDataCollector.php index 06c56b3..efb774d 100644 --- a/src/Bridges/SymfonyBundle/DataCollector/QueryDataCollector.php +++ b/src/Bridges/SymfonyBundle/DataCollector/QueryDataCollector.php @@ -46,7 +46,7 @@ public function getName() } - public function collect(Request $request, Response $response, \Throwable $exception = null): void + public function collect(Request $request, Response $response, \Throwable|null $exception = null): void { foreach ($this->queries as [$sqlQuery, $timeTaken, $rowsCount]) { $row = [ diff --git a/src/Drivers/Exception/DriverException.php b/src/Drivers/Exception/DriverException.php index 1b91830..a6f8825 100644 --- a/src/Drivers/Exception/DriverException.php +++ b/src/Drivers/Exception/DriverException.php @@ -12,7 +12,7 @@ public function __construct( string $message, private readonly int $errorCode = 0, private readonly string $errorSqlState = '', - Exception $previousException = null + Exception|null $previousException = null ) { parent::__construct($message, 0, $previousException); diff --git a/src/Drivers/Exception/QueryException.php b/src/Drivers/Exception/QueryException.php index 5c98e17..953d87c 100644 --- a/src/Drivers/Exception/QueryException.php +++ b/src/Drivers/Exception/QueryException.php @@ -12,7 +12,7 @@ public function __construct( string $message, int $errorCode = 0, string $errorSqlState = '', - Exception $previousException = null, + Exception|null $previousException = null, private readonly ?string $sqlQuery = null ) { diff --git a/src/Drivers/Exception/UnknownMysqlTimezoneException.php b/src/Drivers/Exception/UnknownMysqlTimezoneException.php index 2ae8278..47eab91 100644 --- a/src/Drivers/Exception/UnknownMysqlTimezoneException.php +++ b/src/Drivers/Exception/UnknownMysqlTimezoneException.php @@ -12,7 +12,7 @@ public function __construct( string $message, int $errorCode = 0, string $errorSqlState = '', - Exception $previousException = null, + Exception|null $previousException = null, ?string $sqlQuery = null, ) { From be5d1b1ee89d196c47281466a87b7c7c1af1cc9c Mon Sep 17 00:00:00 2001 From: Jan Skrasek Date: Sat, 9 Nov 2024 18:30:25 +0100 Subject: [PATCH 3/5] replace MYSQLI_TYPE_INTERVAL for PHP 8.4 compatibility --- src/Drivers/Mysqli/MysqliResultNormalizerFactory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Drivers/Mysqli/MysqliResultNormalizerFactory.php b/src/Drivers/Mysqli/MysqliResultNormalizerFactory.php index 1de9f19..21863c2 100644 --- a/src/Drivers/Mysqli/MysqliResultNormalizerFactory.php +++ b/src/Drivers/Mysqli/MysqliResultNormalizerFactory.php @@ -76,7 +76,7 @@ public function resolve(array $types): array static $ints = [ MYSQLI_TYPE_BIT => true, MYSQLI_TYPE_INT24 => true, - MYSQLI_TYPE_INTERVAL => true, + MYSQLI_TYPE_ENUM => true, MYSQLI_TYPE_TINY => true, MYSQLI_TYPE_SHORT => true, MYSQLI_TYPE_LONG => true, From a9ddc3747fe877023f50010dfb7e95be6b05f2b6 Mon Sep 17 00:00:00 2001 From: Jan Skrasek Date: Sat, 9 Nov 2024 19:50:12 +0100 Subject: [PATCH 4/5] relax dev-deps to properly build with PHP 8.4 --- composer.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 31af6b9..46a8cb9 100644 --- a/composer.json +++ b/composer.json @@ -20,10 +20,10 @@ "nette/tester": "~2.4", "nette/caching": "~3.0", "nette/di": "~3.0", - "nette/utils": "~3.0", - "nette/finder": "~2.5", + "nette/utils": "~3.0 || ~4.0", + "nette/finder": "~2.5 || ~3.0", "nette/neon": "~3.0", - "nextras/multi-query-parser": "1.0.0", + "nextras/multi-query-parser": "~1.0", "phpstan/extension-installer": "1.4.3", "phpstan/phpstan": "1.12.6", "phpstan/phpstan-deprecation-rules": "1.1.4", From bcb1373d0e22b87b0784501716d15235d8b9deef Mon Sep 17 00:00:00 2001 From: Jan Skrasek Date: Sat, 9 Nov 2024 20:00:20 +0100 Subject: [PATCH 5/5] replace Mysqli::ping() with simple SELECT 1 to fix PHP 8.4 deprecation --- src/Drivers/Mysqli/MysqliDriver.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Drivers/Mysqli/MysqliDriver.php b/src/Drivers/Mysqli/MysqliDriver.php index b2eea6e..81054f2 100644 --- a/src/Drivers/Mysqli/MysqliDriver.php +++ b/src/Drivers/Mysqli/MysqliDriver.php @@ -209,8 +209,12 @@ public function getServerVersion(): string public function ping(): bool { $this->checkConnection(); - assert($this->connection !== null); - return $this->connection->ping(); + try { + $this->query('SELECT 1'); + return true; + } catch (DriverException) { + return false; + } }