From b063c9ebe015dc78786dd5815a57ef89b07639ec Mon Sep 17 00:00:00 2001 From: Hans Ott Date: Thu, 22 Oct 2026 11:47:31 +0200 Subject: [PATCH] Report actual PHP version, not the one we compiled against --- lib/php-extension/RequestProcessor.cpp | 10 +++++++++- tests/server/test_platform_version/index.php | 3 +++ .../test_platform_version/start_config.json | 10 ++++++++++ tests/server/test_platform_version/test.py | 17 +++++++++++++++++ 4 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 tests/server/test_platform_version/index.php create mode 100755 tests/server/test_platform_version/start_config.json create mode 100644 tests/server/test_platform_version/test.py diff --git a/lib/php-extension/RequestProcessor.cpp b/lib/php-extension/RequestProcessor.cpp index bb5aca99f..5e000c6b7 100644 --- a/lib/php-extension/RequestProcessor.cpp +++ b/lib/php-extension/RequestProcessor.cpp @@ -76,6 +76,14 @@ bool RequestProcessor::Init() { return true; } +static std::string GetRuntimePhpVersion() { + zval* version = zend_get_constant_str(ZEND_STRL("PHP_VERSION")); + if (version && Z_TYPE_P(version) == IS_STRING) { + return Z_STRVAL_P(version); + } + return ""; +} + std::string RequestProcessor::GetInitData(const std::string& userProvidedToken) { LoadEnvironment(); @@ -91,7 +99,7 @@ std::string RequestProcessor::GetInitData(const std::string& userProvidedToken) json initData = { {"token", globalToken}, {"platform_name", AIKIDO_GLOBAL(sapi_name)}, - {"platform_version", PHP_VERSION}, + {"platform_version", GetRuntimePhpVersion()}, {"endpoint", AIKIDO_GLOBAL(endpoint)}, {"config_endpoint", AIKIDO_GLOBAL(config_endpoint)}, {"log_level", AIKIDO_GLOBAL(log_level_str)}, diff --git a/tests/server/test_platform_version/index.php b/tests/server/test_platform_version/index.php new file mode 100644 index 000000000..d482b288a --- /dev/null +++ b/tests/server/test_platform_version/index.php @@ -0,0 +1,3 @@ +