From c827c93b62186488dbffdf4b614413ae7a785607 Mon Sep 17 00:00:00 2001 From: Dan Wallis Date: Wed, 11 Oct 2023 13:19:31 +0100 Subject: [PATCH] Use global constant if available for libpq version (#11684) --- src/Composer/Repository/PlatformRepository.php | 6 ++++++ tests/Composer/Test/Repository/PlatformRepositoryTest.php | 2 ++ 2 files changed, 8 insertions(+) diff --git a/src/Composer/Repository/PlatformRepository.php b/src/Composer/Repository/PlatformRepository.php index 9ab0f6c6b..2f8f206e8 100644 --- a/src/Composer/Repository/PlatformRepository.php +++ b/src/Composer/Repository/PlatformRepository.php @@ -449,6 +449,12 @@ class PlatformRepository extends ArrayRepository break; case 'pgsql': + if ($this->runtime->hasConstant('PGSQL_LIBPQ_VERSION')) { + $this->addLibrary('pgsql-libpq', $this->runtime->getConstant('PGSQL_LIBPQ_VERSION'), 'libpq for pgsql'); + break; + } + // intentional fall-through to next case... + case 'pdo_pgsql': $info = $this->runtime->getExtensionInfo($name); diff --git a/tests/Composer/Test/Repository/PlatformRepositoryTest.php b/tests/Composer/Test/Repository/PlatformRepositoryTest.php index 9e791a776..74f6c3179 100644 --- a/tests/Composer/Test/Repository/PlatformRepositoryTest.php +++ b/tests/Composer/Test/Repository/PlatformRepositoryTest.php @@ -998,6 +998,8 @@ pgsql.auto_reset_persistent => Off => Off pgsql.ignore_notice => Off => Off pgsql.log_notice => Off => Off', ['lib-pgsql-libpq' => '12.2'], + [], + [['PGSQL_LIBPQ_VERSION', null, '12.2']], ], 'pdo_pgsql' => [ 'pdo_pgsql',