Skip to content

PHPC-2275: Always consult php-config for PHP version check in config.m4 #1477

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

Merged
merged 1 commit into from
Oct 10, 2023

Conversation

jmikola
Copy link
Member

@jmikola jmikola commented Oct 6, 2023

https://jira.mongodb.org/browse/PHPC-2275

Typically, PHP_VERSION and PHP_VERSION_ID are only defined when building the extension statically with PHP, since those variables are defined in php-src's own configure.ac. The variables are not defined when using phpize for a shared build.

The PHP Docker images for Alpine happen to define PHP_VERSION in their shell, but not PHP_VERSION_ID, which resulted in an "sh: out of range" error attempting to check the version. The shell-defined PHP_VERSION is also not necessarily the value we'd get from php-config (edge case where someone installs a different PHP version on top of an existing image).

This changes the logic to always rely on php-config to derive these values, as is done in various other extensions (e.g. xdebug, parallel). The awk one-liner that calculates PHP_VERSION_ID is also replaced with a direct call to php-config --vernum, which has been available since PHP 5.4 (php/php-src@f0fe4e0).


Note: this has been manually tested on Alpine using 7.4.0-fpm-alpine, which required manually installing additional packges to compile the driver:

$ apk add git autoconf build-base

Typically, PHP_VERSION and PHP_VERSION_ID are only defined when building the extension statically with PHP, since those variables are defined in php-src's own configure.ac. The variables are not defined when using phpize for a shared build.

The PHP Docker images for Alpine happen to define PHP_VERSION in their shell, but not PHP_VERSION_ID, which resulted in an "sh: out of range" error attempting to check the version. The shell-defined PHP_VERSION is also not necessarily the value we'd get from php-config (edge case where someone installs a different PHP version on top of an existing image).

This changes the logic to always rely on php-config to derive these values, as is done in various other extensions (e.g. xdebug, parallel). The awk one-liner that calculates PHP_VERSION_ID is also replaced with a direct call to `php-config --vernum`, which has been available since PHP 5.4 (php/php-src@f0fe4e0).
@jmikola jmikola merged commit befb835 into mongodb:master Oct 10, 2023
@jmikola jmikola deleted the phpc-2275 branch October 10, 2023 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants