Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: display libpq version with composer show -p command #11683

Closed
llaville opened this issue Oct 10, 2023 · 12 comments
Closed

Feature: display libpq version with composer show -p command #11683

llaville opened this issue Oct 10, 2023 · 12 comments
Labels
Milestone

Comments

@llaville
Copy link

Hello,

This is not a bug, but will help to debug depending on current platform.
Recently, I've begun to start to implement PHP 8.3 support on my project https://github.com/llaville/php-compatinfo-db and when I update the pgsql extension reference, I've noticed that new PGSQL_ERRORS_SQLSTATE constant added since PHP 8.3.0alpha1 (see php/php-src@f31d253#diff-c5961ea04ab805b0059964fac68d6e159095a4b56aaaded0b1b941b8768c0f52) depends on libpq > 11.0

BTW, Composer 2.6 did not yet display version of libpq extension with the composer show -p command.

Running 2.6.5 (2023-10-06 10:11:52) with PHP 8.3.0RC3 on Linux / 5.15.90.1-microsoft-standard-WSL2
Reading ./composer.json (/shared/backups/bartlett/php-compatinfo-db/composer.json)
Loading config file ./composer.json (/shared/backups/bartlett/php-compatinfo-db/composer.json)
Checked CA file /etc/pki/tls/certs/ca-bundle.crt does not exist or it is not a file.
Checked directory /etc/pki/tls/certs/ca-bundle.crt does not exist or it is not a directory.
Checked CA file /etc/ssl/certs/ca-certificates.crt: valid
Executing command (/shared/backups/bartlett/php-compatinfo-db): 'git' 'branch' '-a' '--no-color' '--no-abbrev' '-v'
Failed to initialize global composer: Composer could not find the config file: /home/devilbox/.composer/composer.json

Reading /shared/backups/bartlett/php-compatinfo-db/vendor/composer/installed.json
Loading plugin cweagans\Composer\Patches (from cweagans/composer-patches)
composer                2.6.5     Composer package
composer-plugin-api     2.6.0     The Composer Plugin API
composer-runtime-api    2.2.2     The Composer Runtime API
ext-amqp                2.1.0     The amqp PHP extension
ext-apcu                5.1.22    The apcu PHP extension
ext-ast                 1.1.0     The ast PHP extension
ext-bcmath              8.3.0RC3  The bcmath PHP extension
ext-bz2                 8.3.0RC3  The bz2 PHP extension
ext-calendar            8.3.0RC3  The calendar PHP extension
ext-ctype               8.3.0RC3  The ctype PHP extension
ext-curl                8.3.0RC3  The curl PHP extension
ext-date                8.3.0RC3  The date PHP extension
ext-dba                 8.3.0RC3  The dba PHP extension
ext-dom                 20031129  The dom PHP extension
ext-enchant             8.3.0RC3  The enchant PHP extension
ext-exif                8.3.0RC3  The exif PHP extension
ext-fileinfo            8.3.0RC3  The fileinfo PHP extension
ext-filter              8.3.0RC3  The filter PHP extension
ext-ftp                 8.3.0RC3  The ftp PHP extension
ext-gd                  8.3.0RC3  The gd PHP extension
ext-gettext             8.3.0RC3  The gettext PHP extension
ext-gmp                 8.3.0RC3  The gmp PHP extension
ext-hash                8.3.0RC3  The hash PHP extension
ext-http                4.2.4     The http PHP extension
ext-iconv               8.3.0RC3  The iconv PHP extension
ext-igbinary            3.2.14    The igbinary PHP extension
ext-imagick             3.7.0     The imagick PHP extension
ext-imap                8.3.0RC3  The imap PHP extension
ext-intl                8.3.0RC3  The intl PHP extension
ext-json                8.3.0RC3  The json PHP extension
ext-ldap                8.3.0RC3  The ldap PHP extension
ext-libxml              8.3.0RC3  The libxml PHP extension
ext-lzf                 1.7.0     The lzf PHP extension
ext-mailparse           3.1.6     The mailparse PHP extension
ext-mbstring            8.3.0RC3  The mbstring PHP extension
ext-mcrypt              1.0.6     The mcrypt PHP extension
ext-memcache            8.2       The memcache PHP extension
ext-memcached           3.2.0     The memcached PHP extension
ext-mongodb             1.16.2    The mongodb PHP extension
ext-msgpack             2.2.0     The msgpack PHP extension
ext-mysqli              8.3.0RC3  The mysqli PHP extension
ext-mysqlnd             0         The mysqlnd PHP extension (actual version: mysqlnd 8.3.0RC3)
ext-oauth               2.0.7     The OAuth PHP extension
ext-oci8                3.3.0     The oci8 PHP extension
ext-odbc                8.3.0RC3  The odbc PHP extension
ext-openssl             8.3.0RC3  The openssl PHP extension
ext-pcntl               8.3.0RC3  The pcntl PHP extension
ext-pcre                8.3.0RC3  The pcre PHP extension
ext-pdo                 8.3.0RC3  The PDO PHP extension
ext-pdo_dblib           8.3.0RC3  The pdo_dblib PHP extension
ext-pdo_firebird        8.3.0RC3  The PDO_Firebird PHP extension
ext-pdo_mysql           8.3.0RC3  The pdo_mysql PHP extension
ext-pdo_oci             8.3.0RC3  The PDO_OCI PHP extension
ext-pdo_odbc            8.3.0RC3  The PDO_ODBC PHP extension
ext-pdo_pgsql           8.3.0RC3  The pdo_pgsql PHP extension
ext-pdo_sqlite          8.3.0RC3  The pdo_sqlite PHP extension
ext-pgsql               8.3.0RC3  The pgsql PHP extension
ext-phar                8.3.0RC3  The Phar PHP extension
ext-posix               8.3.0RC3  The posix PHP extension
ext-pspell              8.3.0RC3  The pspell PHP extension
ext-random              8.3.0RC3  The random PHP extension
ext-raphf               2.0.1     The raphf PHP extension
ext-readline            8.3.0RC3  The readline PHP extension
ext-redis               6.0.1     The redis PHP extension
ext-reflection          8.3.0RC3  The Reflection PHP extension
ext-session             8.3.0RC3  The session PHP extension
ext-shmop               8.3.0RC3  The shmop PHP extension
ext-simplexml           8.3.0RC3  The SimpleXML PHP extension
ext-snmp                8.3.0RC3  The snmp PHP extension
ext-soap                8.3.0RC3  The soap PHP extension
ext-sockets             8.3.0RC3  The sockets PHP extension
ext-sodium              8.3.0RC3  The sodium PHP extension
ext-spl                 8.3.0RC3  The SPL PHP extension
ext-sqlite3             8.3.0RC3  The sqlite3 PHP extension
ext-ssh2                1.4       The ssh2 PHP extension
ext-stomp               2.0.3     The Stomp PHP extension
ext-sysvmsg             8.3.0RC3  The sysvmsg PHP extension
ext-sysvsem             8.3.0RC3  The sysvsem PHP extension
ext-sysvshm             8.3.0RC3  The sysvshm PHP extension
ext-tidy                8.3.0RC3  The tidy PHP extension
ext-tokenizer           8.3.0RC3  The tokenizer PHP extension
ext-uploadprogress      2.0.2     The uploadprogress PHP extension
ext-uuid                1.2.0     The uuid PHP extension
ext-xhprof              2.3.9     The xhprof PHP extension
ext-xlswriter           1.5.5     The xlswriter PHP extension
ext-xml                 8.3.0RC3  The xml PHP extension
ext-xmldiff             1.1.3     The xmldiff PHP extension
ext-xmlreader           8.3.0RC3  The xmlreader PHP extension
ext-xmlrpc              1.0.0RC3  The xmlrpc PHP extension
ext-xmlwriter           8.3.0RC3  The xmlwriter PHP extension
ext-xsl                 8.3.0RC3  The xsl PHP extension
ext-yac                 2.3.1     The yac PHP extension
ext-yaml                2.2.3     The yaml PHP extension
ext-zend-opcache        8.3.0RC3  The Zend OPcache PHP extension
ext-zip                 1.22.2    The zip PHP extension
ext-zlib                8.3.0RC3  The zlib PHP extension
lib-amqp-librabbitmq    0.11.0    AMQP librabbitmq version
lib-amqp-protocol       0.9.1     AMQP protocol version
lib-bz2                 1.0.8     The bz2 library
lib-curl                7.88.1    The curl library
lib-curl-libssh2        1.10.0    curl libssh2 version
lib-curl-openssl        3.0.9     curl OpenSSL version (3.0.9)
lib-curl-zlib           1.2.13    curl zlib version
lib-date-timelib        2022.09   date timelib version
lib-date-zoneinfo       2023.3    zoneinfo ("Olson") database for date
lib-fileinfo-libmagic   543       fileinfo libmagic version
lib-gd                  2.0.35    The gd library
lib-gd-freetype         2.12.1    freetype version for gd
lib-gd-libjpeg          6.2       libjpeg version for gd
lib-gd-libpng           1.6.39    libpng version for gd
lib-gd-libxpm           3.4.11    libxpm version for gd
lib-gmp                 6.2.1     The gmp library
lib-iconv               2.36      The iconv library
lib-icu                 72.1      The ICU unicode and globalization support library
lib-icu-cldr            42        ICU CLDR project version
lib-icu-unicode         15.0.0    ICU unicode version
lib-icu-zoneinfo        2022.5    zoneinfo ("Olson") database for icu
lib-imagick-imagemagick 6.9.11.60 The imagick-imagemagick library
lib-ldap-openldap       2.5.13    OpenLDAP version of ldap
lib-libsodium           1.0.18    The libsodium library
lib-libxml              2.9.14    libxml library version
lib-libxslt             1.1.35    The libxslt library
lib-libxslt-libxml      2.9.14    libxml version libxslt is compiled against
lib-mbstring-libmbfl    1.3.2     mbstring libmbfl version
lib-mbstring-oniguruma  6.9.8     mbstring oniguruma version
lib-mongodb-libbson     1.24.3    libbson version of mongodb
lib-mongodb-libmongoc   1.24.3    libmongoc version of mongodb
lib-openssl             3.0.9     OpenSSL 3.0.9 30 May 2023
lib-pcre                10.42     The pcre library
lib-pcre-unicode        14.0.0    PCRE Unicode version support
lib-pdo_pgsql-libpq     15.3      libpq for pdo_pgsql
lib-pdo_sqlite-sqlite   3.40.1    The pdo_sqlite-sqlite library
lib-sqlite3-sqlite      3.40.1    The sqlite3-sqlite library
lib-ssh2-libssh2        1.10.0    The ssh2-libssh2 library
lib-yaml-libyaml        0.2.5     libyaml version of yaml
lib-zip-libzip          1.7.3     The zip-libzip library
lib-zlib                1.2.13    The zlib library
php                     8.3.0RC3  The PHP interpreter
php-64bit               8.3.0RC3  The PHP interpreter, 64bit
php-ipv6                8.3.0RC3  The PHP interpreter, with IPv6 support

Native php --ri pqsql command print following output (on my platform) :

pgsql

PostgreSQL Support => enabled
PostgreSQL (libpq) Version => 15.3
Multibyte character support => enabled
Active Persistent Links => 0
Active Links => 0

Directive => Local Value => Master Value
pgsql.allow_persistent => On => On
pgsql.max_persistent => Unlimited => Unlimited
pgsql.max_links => Unlimited => Unlimited
pgsql.auto_reset_persistent => Off => Off
pgsql.ignore_notice => Off => Off
pgsql.log_notice => Off => Off

Is it possible to add support to this library (with a new call to \Composer\Repository\PlatformRepository::addLibrary) ?
Thanks

@llaville
Copy link
Author

Additional Info : constant PGSQL_LIBPQ_VERSION (is available only since PHP 8.2.0beta2 => php/php-src@eae893b) allow to know libpq version

In my case php -r "echo PGSQL_LIBPQ_VERSION;" gave 15.3

@Seldaek
Copy link
Member

Seldaek commented Oct 11, 2023

Yes, feel free to send a PR for this adding support for it in PlatformRepo. If the constant is available we can use it, if not available you can probably extract it anyway see other usages of $this->runtime->getExtensionInfo(...)

@Seldaek Seldaek added this to the Nice To Have milestone Oct 11, 2023
@llaville
Copy link
Author

llaville commented Oct 11, 2023

Finally it's not a new feature because we have already included it (https://github.com/composer/composer/blob/2.6.5/src/Composer/Repository/PlatformRepository.php#L451-L458)

And it's referenced by lib-pdo_pgsql-libpq 11.20 libpq for pdo_pgsql

I didn't saw it, because I've both pgsql and pdo_pgsql extensions loaded

Saw it know, because I've deepthly analysed source code of v2.6.5

PS: tested with PHP 8.0 here, but my previous attempt with PHP 8.3 gave lib-pdo_pgsql-libpq 15.3 libpq for pdo_pgsql

@llaville
Copy link
Author

I'll close now, sorry to disturb !

@Seldaek
Copy link
Member

Seldaek commented Oct 11, 2023

If you still want to provide an optimization in case the global constant is defined for php 8.2+ that'd be great :)

@Seldaek
Copy link
Member

Seldaek commented Oct 11, 2023

btw I have a feeling PGSQL_LIBPQ_VERSION has been available for longer than 8.2, that commit you linked just moved it as far as I can tell.

@llaville
Copy link
Author

Will check it for global constant in few hours now.

@llaville
Copy link
Author

ok to propose an optimization will constant if available

@Seldaek
Copy link
Member

Seldaek commented Oct 11, 2023

Fixed by #11684

@Seldaek Seldaek closed this as completed Oct 11, 2023
@Seldaek Seldaek modified the milestones: Nice To Have, 2.6 Oct 11, 2023
@llaville
Copy link
Author

llaville commented Oct 11, 2023

btw I have a feeling PGSQL_LIBPQ_VERSION has been available for longer than 8.2, that commit you linked just moved it as far as I can tell.

@Seldaek You've a good feeling ! This constant was introduced in PHP 5.4.4
Confirmed by my project https://github.com/llaville/php-compatinfo-db/blob/master/data/reference/extension/pgsql/54/constants.json and the official PHP commit php/php-src@cce0f8e

So It'll be a really good optimization now to use it, rather than PREG usage ;-)

@fredden You beat me in race ;-) Nice !

@fredden
Copy link
Contributor

fredden commented Oct 11, 2023

You beat me in race ;-) Nice !

Sorry about that. I didn't see that your comments until after I'd opened the pull request.

@llaville
Copy link
Author

You beat me in race ;-) Nice !

Sorry about that. I didn't see that your comments until after I'd opened the pull request.

Don't worry. Less works for me to do ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants