diff --git a/.gitlab/ci-images.yml b/.gitlab/ci-images.yml index 368c5b1bbb9..ada2c69672f 100644 --- a/.gitlab/ci-images.yml +++ b/.gitlab/ci-images.yml @@ -20,6 +20,7 @@ CentOS: matrix: - PHP_VERSION: - base + - php-8.5 - php-8.4 - php-8.3 - php-8.2 @@ -47,6 +48,7 @@ Alpine: matrix: - PHP_VERSION: - base-alpine + - 8.5-alpine - 8.4-alpine - 8.3-alpine - 8.2-alpine @@ -74,6 +76,7 @@ Bookworm: matrix: - PHP_VERSION: - base + - php-8.5 - php-8.4 - php-8.3 - php-8.2 @@ -103,6 +106,7 @@ Buster: matrix: - PHP_VERSION: - base + - php-8.5 - php-8.4 - php-8.3 - php-8.2 diff --git a/.gitlab/generate-appsec.php b/.gitlab/generate-appsec.php index 68dacba0532..fc1faf3d840 100644 --- a/.gitlab/generate-appsec.php +++ b/.gitlab/generate-appsec.php @@ -132,6 +132,8 @@ - test8.3-release-zts - test8.4-release - test8.4-release-zts + - test8.5-release + - test8.5-release-zts before_script: script: diff --git a/.gitlab/generate-common.php b/.gitlab/generate-common.php index ada5c9f9c33..b6c1193f097 100644 --- a/.gitlab/generate-common.php +++ b/.gitlab/generate-common.php @@ -13,6 +13,7 @@ "8.2" => "20220829", "8.3" => "20230831", "8.4" => "20240924", + "8.5" => "20250925", ]; $all_minor_major_targets = array_keys($php_versions_to_abi); diff --git a/.gitlab/generate-tracer.php b/.gitlab/generate-tracer.php index 8f4e7bbb6bb..e07818c53fc 100644 --- a/.gitlab/generate-tracer.php +++ b/.gitlab/generate-tracer.php @@ -652,6 +652,7 @@ function before_script_steps() { ["8.2", "3.2.2"], ["8.3", "3.3.2"], ["8.4", "3.4.0"], + // ["8.5", "3.4.5"], Xdebug not supported yet on 8.5 ]; foreach ($xdebug_test_matrix as [$major_minor, $xdebug]): ?> diff --git a/Makefile b/Makefile index c120d2441b3..097936728b2 100644 --- a/Makefile +++ b/Makefile @@ -176,7 +176,7 @@ test_c_observer: $(SO_FILE) $(TEST_FILES) $(TEST_STUB_FILES) $(BUILD_DIR)/run-te $(if $(ASAN), USE_ZEND_ALLOC=0 USE_TRACKED_ALLOC=1) $(ALL_TEST_ENV_OVERRIDE) $(RUN_TESTS_CMD) -d extension=$(SO_FILE) -d extension=zend_test.so -d zend_test.observer.enabled=1 -d zend_test.observer.observe_all=1 -d zend_test.observer.show_output=0 $(BUILD_DIR)/$(TESTS) test_opcache: $(SO_FILE) $(TEST_OPCACHE_FILES) $(BUILD_DIR)/run-tests.php - $(if $(ASAN), USE_ZEND_ALLOC=0 USE_TRACKED_ALLOC=1) $(RUN_TESTS_CMD) -d extension=$(SO_FILE) -d zend_extension=opcache.so $(BUILD_DIR)/tests/opcache + $(if $(ASAN), USE_ZEND_ALLOC=0 USE_TRACKED_ALLOC=1) $(RUN_TESTS_CMD) -d extension=$(SO_FILE) $(shell test $(PHP_MAJOR_MINOR) -lt 85 && echo "-d zend_extension=opcache.so") $(BUILD_DIR)/tests/opcache test_c_mem: $(SO_FILE) $(TEST_FILES) $(TEST_STUB_FILES) $(BUILD_DIR)/run-tests.php $(RUN_TESTS_CMD) -d extension=$(SO_FILE) -m $(BUILD_DIR)/$(TESTS) diff --git a/appsec/tests/extension/module_order_opcache.phpt b/appsec/tests/extension/module_order_opcache.phpt index 689e5a56b32..bda8badaa50 100644 --- a/appsec/tests/extension/module_order_opcache.phpt +++ b/appsec/tests/extension/module_order_opcache.phpt @@ -5,6 +5,8 @@ Verify ddappsec is always in the module registry after ddtrace when opcache is p if (!extension_loaded('Zend OPcache')) { die('skip requires opcache'); } +if (!version_compare(PHP_VERSION, '8.5.0', '>=')) + die('skip: opcache is loaded by default in PHP 8.5+'); ?> --INI-- extension=ddtrace.so diff --git a/appsec/tests/integration/build.gradle b/appsec/tests/integration/build.gradle index 7a2a3088f84..0547b8e6a8f 100644 --- a/appsec/tests/integration/build.gradle +++ b/appsec/tests/integration/build.gradle @@ -42,7 +42,7 @@ test { } tasks['test'].enabled(false) -ext.testMatrix = ['7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4'].collectMany { +ext.testMatrix = ['7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5'].collectMany { [[it, 'release'], [it, 'debug'], [it, 'release-zts']] } ext.uuid = "id -u".execute().text.trim() diff --git a/appsec/tests/integration/gradle/images.gradle b/appsec/tests/integration/gradle/images.gradle index fddebf75e4f..b405df03bd6 100644 --- a/appsec/tests/integration/gradle/images.gradle +++ b/appsec/tests/integration/gradle/images.gradle @@ -34,6 +34,7 @@ def phpVersions = [ '8.2': '8.2.13', '8.3': '8.3.0', '8.4': '8.4.0', + '8.5': '8.5.0', ] def arch = System.getProperty('os.arch') diff --git a/appsec/tests/integration/gradle/tag_mappings.gradle b/appsec/tests/integration/gradle/tag_mappings.gradle index eb81bd003c5..4fc7ddd1dad 100644 --- a/appsec/tests/integration/gradle/tag_mappings.gradle +++ b/appsec/tests/integration/gradle/tag_mappings.gradle @@ -124,5 +124,17 @@ ext.tag_mappings = [ 'php-7.0-release-zts': 'sha256:4bb5fac6fbd3124234d062328c68f6c51027aa95f13e4e8b14afd7c8de518ec6', 'apache2-mod-php-8.4-release': 'sha256:79c2d7dd843b18ce2c5f929e6300e9a1f64a5e00a7edbaeb9f75d8a60b2be3d2', 'php-7.0-release': 'sha256:627c4f460fa1c11f3f5da44d9361eba5de9f38134189ca05b3bfdb9979011e44', - 'php-7.1-release-zts': 'sha256:d997b9f99c28967872bd0949f8572b089daaadb6ceaa1e856ccc76e07e2ba6b7' + 'php-7.1-release-zts': 'sha256:d997b9f99c28967872bd0949f8572b089daaadb6ceaa1e856ccc76e07e2ba6b7', + 'php-8.5-release': 'sha256:85006ca959faac9762c71d2c04456da7b3e668f9433760074170ade846465c2a', + 'php-8.5-release-zts': 'sha256:e93dad03fde7f3771bd2390cd34fc2aadd6f2ad2065ec458c06710713a24ff90', + 'php-8.5-debug': 'sha256:fff058d6ed5a2de5f06f3c8d1c157879a4926294e17190ff8bcfe54cdfaf025f', + 'apache2-fpm-php-8.5-release-zts': 'sha256:45d4416f0ccb887074b4a4c6406c71533a84049312b454c28fc33d18c1fe00fb', + 'apache2-fpm-php-8.5-release': 'sha256:1b9b9fb033e20ac867a684adb9084a6ceefa1812baa39308cca47013ce2cf705', + 'apache2-fpm-php-8.5-debug': 'sha256:9e82028aac75eb916455938f59d68e412307fcfcad1d4eb37e6d4a75e7a61269', + 'apache2-mod-php-8.5-release-zts': 'sha256:f3e8741683433b0fd43ee0eb8dd197b91d6b3e56122963f20df46858c78462d7', + 'apache2-mod-php-8.5-release': 'sha256:12ffe23c006de6d74279b0e53390f023bb1f3d132e4d0cbff3a4fd684a9761d2', + 'apache2-mod-php-8.5-debug': 'sha256:d16455deab5f5a68b5b3d0ac18e3904d51ff6c30a0107148944b7a6467517edc', + 'nginx-fpm-php-8.5-release-zts': 'sha256:a2ecb6bdb630debd9ea61be9b32acd975361f1d13fe2ad325a0dff4b9ef1ea2c', + 'nginx-fpm-php-8.5-release': 'sha256:a6a4ff845b68a3e2a35399bedab758e9b47a48ad669e3c9f2f4f3a9367c3ad10', + 'nginx-fpm-php-8.5-debug': 'sha256:a62ce17ddb04879e1d3c383ccaf53eb1cbe8e6711679383045dd3de81aed1b47' ] diff --git a/appsec/tests/integration/src/docker/php/build_dev_php.sh b/appsec/tests/integration/src/docker/php/build_dev_php.sh index c7688f2af28..660f99db2de 100755 --- a/appsec/tests/integration/src/docker/php/build_dev_php.sh +++ b/appsec/tests/integration/src/docker/php/build_dev_php.sh @@ -36,8 +36,8 @@ function download_php { local download_url if [[ $version_id -lt 50400 ]]; then download_url="http://museum.php.net/php5/php-${version}.tar.gz" - elif [[ $version_id -ge 80400 ]]; then - download_url="https://downloads.php.net/~saki/php-8.4.0RC3.tar.gz" + elif [[ $version_id -ge 80500 ]]; then + download_url="https://downloads.php.net/~daniels/php-8.5.0RC1.tar.gz" else download_url="https://www.php.net/distributions/php-${version}.tar.gz" fi @@ -81,7 +81,7 @@ chmod +x /tmp/apxs_wrapper } function run_dsymutil { - if [[ $(uname) != Darwin ]] then + if [[ $(uname) != Darwin ]]; then return fi local readonly dir=$1 exe= diff --git a/datadog-setup.php b/datadog-setup.php index c38cdab7715..054fc9839eb 100644 --- a/datadog-setup.php +++ b/datadog-setup.php @@ -549,12 +549,12 @@ function install($options) $tar_gz_suffix = ""; // retry with the full archive if the original download failed } } - if (!IS_WINDOWS || `where tar 2> nul` !== null) { + if (!IS_WINDOWS || shell_exec("where tar 2> nul") !== null) { execute_or_exit( "Cannot extract the archive", "tar -xf " . escapeshellarg($tmpDirTarGz) . " -C " . escapeshellarg($tmpDir) ); - } elseif (($defaultPath = `where 7z 2> nul`) !== null || @is_dir($installDir7z = getenv("PROGRAMFILES") . "\\7-Zip")) { + } elseif (($defaultPath = shell_exec("where 7z 2> nul")) !== null || @is_dir($installDir7z = getenv("PROGRAMFILES") . "\\7-Zip")) { if ($defaultPath === null) { putenv("PATH=" . getenv("PATH") . ";$installDir7z"); } @@ -638,6 +638,7 @@ function install($options) // Trace $extensionRealPath = "$tmpArchiveTraceRoot/ext/$extensionVersion/" . EXTENSION_PREFIX . "ddtrace$extensionSuffix." . EXTENSION_SUFFIX; + if (!file_exists($extensionRealPath)) { print_error_and_exit(substr($extensionSuffix ?: '-nts', 1) . ' builds of PHP ' . $phpProperties[PHP_VER] . ' are currently not supported'); @@ -1506,7 +1507,7 @@ function download($url, $destination, $retry = false) } } - curl_close($ch); + if (PHP_VERSION_ID < 80000) { curl_close($ch); } fclose($fp); if (false !== $return) { @@ -1541,7 +1542,12 @@ function download($url, $destination, $retry = false) // PHP doesn't like too long location headers, and on PHP 7.3 and older they weren't read at all. // But this only really matters for CircleCI artifacts, so not too bad. if ($data == "") { - foreach ($http_response_header as $header) { + if (PHP_VERSION_ID >= 80500) { + $headers = http_get_last_response_headers(); + } else { + $headers = $http_response_header; + } + foreach ($headers as $header) { if (stripos($header, "location: ") === 0) { $data = file_get_contents(substr($header, 10)); goto got_data; diff --git a/docker-compose.yml b/docker-compose.yml index 6db5b89ff17..1dd7b41e307 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -85,6 +85,7 @@ services: '8.2-bookworm': { <<: *linux_php_service, image: 'datadog/dd-trace-ci:php-8.2_bookworm-5' } '8.3-bookworm': { <<: *linux_php_service, image: 'datadog/dd-trace-ci:php-8.3_bookworm-5' } '8.4-bookworm': { <<: *linux_php_service, image: 'datadog/dd-trace-ci:php-8.4_bookworm-5' } + '8.5-bookworm': { <<: *linux_php_service, image: 'datadog/dd-trace-ci:php-8.5_bookworm-5' } 'php-master-buster': { <<: *linux_php_service, image: 'datadog/dd-trace-ci:php-master_buster' } # --- CentOS 6 --- '7.0-centos7': { <<: *linux_php_service, image: 'datadog/dd-trace-ci:php-7.0_centos-7' } @@ -97,6 +98,7 @@ services: '8.2-centos7': { <<: *linux_php_service, image: 'datadog/dd-trace-ci:php-8.2_centos-7' } '8.3-centos7': { <<: *linux_php_service, image: 'datadog/dd-trace-ci:php-8.3_centos-7' } '8.4-centos7': { <<: *linux_php_service, image: 'datadog/dd-trace-ci:php-8.4_centos-7' } + '8.5-centos7': { <<: *linux_php_service, image: 'datadog/dd-trace-ci:php-8.5_centos-7' } # --- Windows --- '7.0-windows': { <<: *windows_php_service, image: 'datadog/dd-trace-ci:php-7.0_windows' } '7.1-windows': { <<: *windows_php_service, image: 'datadog/dd-trace-ci:php-7.1_windows' } @@ -108,6 +110,7 @@ services: '8.2-windows': { <<: *windows_php_service, image: 'datadog/dd-trace-ci:php-8.2_windows' } '8.3-windows': { <<: *windows_php_service, image: 'datadog/dd-trace-ci:php-8.3_windows' } '8.4-windows': { <<: *windows_php_service, image: 'datadog/dd-trace-ci:php-8.4_windows' } + '8.5-windows': { <<: *windows_php_service, image: 'datadog/dd-trace-ci:php-8.5_windows' } rabbitmq-integration: image: rabbitmq:3.8.9-alpine # 3.8.9 is the latest version that supports Erlang 20 diff --git a/dockerfiles/ci/alpine_compile_extension/Dockerfile b/dockerfiles/ci/alpine_compile_extension/Dockerfile index 7de688f59e8..a7a694ec532 100644 --- a/dockerfiles/ci/alpine_compile_extension/Dockerfile +++ b/dockerfiles/ci/alpine_compile_extension/Dockerfile @@ -16,11 +16,11 @@ ENV PHP_API=${phpApi} ENV PHP_URL=${phpTarGzUrl:-https://www.php.net/distributions/php-${phpVersion}.tar.gz} ENV PHP_SHA256=${phpSha256Hash} ENV PHP_SRC_DIR=${SRC_DIR}/php -ENV PHP_INI_DIR /usr/local/etc/php-${phpVersion} +ENV PHP_INI_DIR=/usr/local/etc/php-${phpVersion} ENV PHP_INSTALL_DIR=/usr/local/php-${phpVersion} RUN install-php -ENV PATH ${PATH}:${PHP_INSTALL_DIR}/bin +ENV PATH=${PATH}:${PHP_INSTALL_DIR}/bin ADD ./env-init /root/.bashrc ENV ENV=/root/.bashrc diff --git a/dockerfiles/ci/alpine_compile_extension/docker-compose.yml b/dockerfiles/ci/alpine_compile_extension/docker-compose.yml index ed046143408..531f4b1679c 100644 --- a/dockerfiles/ci/alpine_compile_extension/docker-compose.yml +++ b/dockerfiles/ci/alpine_compile_extension/docker-compose.yml @@ -133,3 +133,16 @@ services: phpApi: 20240924 volumes: - ../../:/app + + 8.5-alpine: + image: datadog/dd-trace-ci:php-compile-extension-alpine-8.5 + build: + context: . + x-bake: *bake + args: + phpVersion: 8.5.0 + phpTarGzUrl: https://downloads.php.net/~daniels/php-8.5.0RC1.tar.gz + phpSha256Hash: "0ea5059a387117fe6ed9a72cdc20945dbff6acc072df936e97d35a9cb26420e0" + phpApi: 20250925 + volumes: + - ../../:/app diff --git a/dockerfiles/ci/bookworm/build-extensions.sh b/dockerfiles/ci/bookworm/build-extensions.sh index e0d34d7c312..bb643e266b8 100755 --- a/dockerfiles/ci/bookworm/build-extensions.sh +++ b/dockerfiles/ci/bookworm/build-extensions.sh @@ -123,24 +123,49 @@ if [[ $SHARED_BUILD -ne 0 ]]; then # TODO Add ext/pdo_mysql, ext/pdo_pgsql, and ext/pdo_sqlite else pecl channel-update pecl.php.net; - - pecl install amqp$AMQP_VERSION; echo "extension=amqp.so" >> ${iniDir}/amqp.ini; yes '' | pecl install apcu; echo "extension=apcu.so" >> ${iniDir}/apcu.ini; pecl install ast$AST_VERSION; echo "extension=ast.so" >> ${iniDir}/ast.ini; if [[ $PHP_VERSION_ID -ge 71 && $PHP_VERSION_ID -le 80 ]]; then yes '' | CFLAGS="-Wno-incompatible-function-pointer-types" pecl install mcrypt$(if [[ $PHP_VERSION_ID -le 71 ]]; then echo -1.0.0; fi); echo "extension=mcrypt.so" >> ${iniDir}/mcrypt.ini; fi - yes 'no' | pecl install memcached; echo "extension=memcached.so" >> ${iniDir}/memcached.ini; - yes '' | pecl install memcache$MEMCACHE_VERSION; echo "extension=memcache.so" >> ${iniDir}/memcache.ini; - pecl install mongodb$MONGODB_VERSION; echo "extension=mongodb.so" >> ${iniDir}/mongodb.ini; + + if [[ $PHP_VERSION_ID -lt 85 ]]; then + pecl install amqp$AMQP_VERSION; echo "extension=amqp.so" >> "${iniDir}/amqp.ini" + yes 'no' | pecl install memcached; echo "extension=memcached.so" >> ${iniDir}/memcached.ini; + yes '' | pecl install memcache$MEMCACHE_VERSION; echo "extension=memcache.so" >> ${iniDir}/memcache.ini; + pecl install mongodb$MONGODB_VERSION; echo "extension=mongodb.so" >> ${iniDir}/mongodb.ini; + + # Xdebug is disabled by default + for VERSION in "${XDEBUG_VERSIONS[@]}"; do + pecl install xdebug$VERSION; + cd $(php-config --extension-dir); + mv xdebug.so xdebug$VERSION.so; + done + else + cd /tmp + + # memcached master version + git clone https://github.com/php-memcached-dev/php-memcached.git + cd php-memcached + phpize && ./configure && make -j"$(nproc)" && make install && echo "extension=memcached.so" >> ${iniDir}/memcached.ini; + cd .. + + # memcache master version + git clone https://github.com/websupport-sk/pecl-memcache.git + cd pecl-memcache + phpize && ./configure && make -j"$(nproc)" && make install && echo "extension=memcache.so" >> ${iniDir}/memcache.ini; + cd .. + + pecl install mongodb$MONGODB_VERSION; echo "extension=mongodb.so" >> ${iniDir}/mongodb.ini; + + # Xdebug master version (disabled by default) + git clone https://github.com/xdebug/xdebug.git + cd xdebug + phpize && ./configure && make -j"$(nproc)" && make install; + cd .. + fi pecl install rdkafka; echo "extension=rdkafka.so" >> ${iniDir}/rdkafka.ini; pecl install sqlsrv$SQLSRV_VERSION; - # Xdebug is disabled by default - for VERSION in "${XDEBUG_VERSIONS[@]}"; do - pecl install xdebug$VERSION; - cd $(php-config --extension-dir); - mv xdebug.so xdebug$VERSION.so; - done echo "zend_extension=opcache.so" >> ${iniDir}/../php-apache2handler.ini; # ext-parallel needs PHP 8 ZTS @@ -150,7 +175,7 @@ else fi # ext-swoole needs PHP 8 - if [[ $PHP_VERSION_ID -ge 80 ]]; then + if [[ $PHP_VERSION_ID -ge 80 && $PHP_VERSION_ID -lt 85 ]]; then pushd /tmp if [[ $PHP_VERSION_ID -ge 83 ]]; then pecl download swoole-6.0.0RC1; @@ -169,7 +194,7 @@ else fi # ext-grpc is needed for google spanner - if [[ $PHP_VERSION_ID -ge 80 ]]; then + if [[ $PHP_VERSION_ID -ge 80 && $PHP_VERSION_ID -lt 85 ]]; then pecl install grpc; # avoid installing it by default, it seems to stall some testsuites. fi @@ -192,7 +217,13 @@ else fi fi if [[ $PHP_VERSION_ID -ge 84 ]]; then - pecl install redis-6.1.0 + if [[ $PHP_VERSION_ID -ge 85 ]]; then + git clone https://github.com/phpredis/phpredis.git + cd phpredis + phpize && ./configure && make -j"$(nproc)" && make install + else + pecl install redis-6.1.0 + fi fi fi diff --git a/dockerfiles/ci/bookworm/build-php.sh b/dockerfiles/ci/bookworm/build-php.sh index 9828b30ecbc..1f3a60de6f7 100755 --- a/dockerfiles/ci/bookworm/build-php.sh +++ b/dockerfiles/ci/bookworm/build-php.sh @@ -46,7 +46,7 @@ ${PHP_SRC_DIR}/configure \ --enable-ftp \ $(if [[ ${PHP_VERSION_ID} -ge 71 ]]; then echo --enable-intl; fi) \ --enable-mbstring \ - --enable-opcache \ + $(if [[ ${PHP_VERSION_ID} -le 84 ]]; then echo --enable-opcache; fi) \ $(if [[ ${PHP_VERSION_ID} -ge 80 ]]; then echo --enable-zend-test=shared; fi) \ --enable-pcntl \ --enable-soap \ diff --git a/dockerfiles/ci/bookworm/docker-compose.yml b/dockerfiles/ci/bookworm/docker-compose.yml index 2880070d0e2..2fca763e6be 100644 --- a/dockerfiles/ci/bookworm/docker-compose.yml +++ b/dockerfiles/ci/bookworm/docker-compose.yml @@ -13,6 +13,18 @@ services: args: &build-base BUILD_BASE: datadog/dd-trace-ci:bookworm-$BOOKWORM_NEXT_VERSION + php-8.5: + image: datadog/dd-trace-ci:php-8.5_bookworm-$BOOKWORM_NEXT_VERSION + build: + context: . + dockerfile: php-8.5/Dockerfile + x-bake: *bake + args: + <<: *build-base + phpVersion: "8.5" + phpTarGzUrl: https://downloads.php.net/~daniels/php-8.5.0RC1.tar.gz + phpSha256Hash: "0ea5059a387117fe6ed9a72cdc20945dbff6acc072df936e97d35a9cb26420e0" + php-8.4: image: datadog/dd-trace-ci:php-8.4_bookworm-$BOOKWORM_NEXT_VERSION build: diff --git a/dockerfiles/ci/bookworm/php-8.5/Dockerfile b/dockerfiles/ci/bookworm/php-8.5/Dockerfile new file mode 100644 index 00000000000..c342f2c81ba --- /dev/null +++ b/dockerfiles/ci/bookworm/php-8.5/Dockerfile @@ -0,0 +1,115 @@ +ARG BUILD_BASE +FROM $BUILD_BASE AS base + +ARG phpVersion +ENV PHP_VERSION=${phpVersion} +ENV LSAN_OPTIONS="suppressions=/home/circleci/suppr.txt,print_suppressions=0" + +COPY php-8.5/suppr.txt /home/circleci/suppr.txt + +FROM --platform=$BUILDPLATFORM $BUILD_BASE AS src +ARG phpTarGzUrl +ARG phpSha256Hash +RUN set -eux; \ + curl -fsSL -o /tmp/php.tar.gz "${phpTarGzUrl}"; \ + (echo "${phpSha256Hash} /tmp/php.tar.gz" | sha256sum -c -); \ + tar xf /tmp/php.tar.gz -C "${PHP_SRC_DIR}" --strip-components=1; \ + rm -f /tmp/php.tar.gz; \ + cd ${PHP_SRC_DIR}; \ + # We need to remove the dl() calls from run-tests as some extensions don't properly switch interned string storage for INIs. \ + sed -i 's/\bdl(/(bool)(/' run-tests.php; \ + ./buildconf --force; + +FROM --platform=$BUILDPLATFORM $BUILD_BASE AS build +ARG phpVersion +ENV PHP_VERSION=${phpVersion} +ENV PHP_INSTALL_DIR=${PHP_INSTALL_DIR} +ARG TARGETPLATFORM +ARG BUILDPLATFORM +# install cross-compiling packages +RUN if [ "$BUILDPLATFORM" != "$TARGETPLATFORM" ]; then \ + sudo dpkg --add-architecture ${TARGETPLATFORM#linux/}; \ + sudo apt update; \ + sudo apt-get install -y --no-install-recommends valgrind:${TARGETPLATFORM#linux/} $(echo $DEVLIBS | sed "s/\(\s\|$\)/:${TARGETPLATFORM#linux/}\1/g"); \ + fi +COPY build-php.sh /home/circleci +COPY --chown=circleci:circleci --from=src $PHP_SRC_DIR $PHP_SRC_DIR + +FROM build AS php-debug +ARG TARGETPLATFORM +RUN /home/circleci/build-php.sh $TARGETPLATFORM $PHP_INSTALL_DIR debug $PHP_VERSION +COPY build-extensions.sh /home/circleci +RUN /home/circleci/build-extensions.sh + +FROM build AS php-nts +ARG TARGETPLATFORM +RUN /home/circleci/build-php.sh $TARGETPLATFORM $PHP_INSTALL_DIR nts $PHP_VERSION +COPY build-extensions.sh /home/circleci +RUN /home/circleci/build-extensions.sh + +FROM build AS php-zts +ARG TARGETPLATFORM +RUN /home/circleci/build-php.sh $TARGETPLATFORM $PHP_INSTALL_DIR zts $PHP_VERSION +COPY build-extensions.sh /home/circleci +RUN /home/circleci/build-extensions.sh + +FROM build AS php-debug-zts-asan +ARG TARGETPLATFORM +RUN /home/circleci/build-php.sh $TARGETPLATFORM $PHP_INSTALL_DIR debug-zts-asan $PHP_VERSION \ + && mv /tmp/build-php/sapi/cli/php /tmp/build-php/sapi/cli/php-asan +# for reasons the asan build just ... crashes in qemu (or executed via bytecode interpreter). The binary itself however perfectly works on the target platform +# just put a working php binary there to continue installation and be happy, then copy back later. +COPY --chown=circleci:circleci --from=php-debug $PHP_INSTALL_DIR/debug/bin/php /tmp/build-php/sapi/cli/php +RUN set -eux; ln -s $PHP_INSTALL_DIR/debug-zts-asan $PHP_INSTALL_DIR/debug; cd /tmp/build-php; touch sapi/cli/php; make install; switch-php debug-zts-asan; +COPY build-extensions.sh /home/circleci +RUN /home/circleci/build-extensions.sh +RUN cp /tmp/build-php/sapi/cli/php-asan $PHP_INSTALL_DIR/debug-zts-asan/bin/php + +FROM build AS php-nts-asan + ARG TARGETPLATFORM + RUN /home/circleci/build-php.sh $TARGETPLATFORM $PHP_INSTALL_DIR nts-asan $PHP_VERSION \ + && mv /tmp/build-php/sapi/cli/php /tmp/build-php/sapi/cli/php-asan + # For reasons the asan build just ... crashes in qemu (or executed via + # bytecode interpreter). The binary itself however perfectly works on the + # target platform. Put a working php binary there to continue installation + # and be happy, then copy back later. + COPY --chown=circleci:circleci --from=php-debug $PHP_INSTALL_DIR/debug/bin/php /tmp/build-php/sapi/cli/php + RUN set -eux; \ + ln -s $PHP_INSTALL_DIR/nts-asan $PHP_INSTALL_DIR/debug; \ + cd /tmp/build-php; \ + touch sapi/cli/php; \ + make install; \ + switch-php nts-asan; + COPY build-extensions.sh /home/circleci + RUN /home/circleci/build-extensions.sh + RUN mv /tmp/build-php/sapi/cli/php-asan $PHP_INSTALL_DIR/nts-asan/bin/php + +FROM base AS final +COPY --chown=circleci:circleci --from=src $PHP_SRC_DIR $PHP_SRC_DIR +COPY --chown=circleci:circleci --from=php-debug-zts-asan $PHP_INSTALL_DIR/debug-zts-asan $PHP_INSTALL_DIR/debug-zts-asan +COPY --chown=circleci:circleci --from=php-nts-asan $PHP_INSTALL_DIR/nts-asan $PHP_INSTALL_DIR/nts-asan +COPY --chown=circleci:circleci --from=php-debug $PHP_INSTALL_DIR/debug $PHP_INSTALL_DIR/debug +COPY --chown=circleci:circleci --from=php-nts $PHP_INSTALL_DIR/nts $PHP_INSTALL_DIR/nts +COPY --chown=circleci:circleci --from=php-zts $PHP_INSTALL_DIR/zts $PHP_INSTALL_DIR/zts + +USER root + +RUN set -eux; \ + sed -i '/report_memleaks=0/d' /opt/php/debug/lib/php/PEAR/RunTest.php; \ + sed -i '/report_memleaks=0/d' /opt/php/debug-zts-asan/lib/php/PEAR/RunTest.php ; \ + sed -i '/report_memleaks=0/d' /opt/php/nts-asan/lib/php/PEAR/RunTest.php; \ + sed -i '/report_memleaks=0/d' /opt/php/zts/lib/php/PEAR/RunTest.php; \ + # Enable the apache config \ + echo "LoadModule php_module /usr/lib/apache2/modules/libphp.so" | tee /etc/apache2/mods-enabled/php.load; \ + # Set the default PHP version + switch-php debug; + +# Install Composer +COPY --from=composer:2 /usr/bin/composer /usr/local/bin/composer + +COPY welcome /etc/motd +RUN sudo sed -i "s/VERSIONS/$(ls $PHP_INSTALL_DIR | xargs)/" /etc/motd + +USER circleci + +CMD ["php-fpm", "-F"] diff --git a/dockerfiles/ci/bookworm/php-8.5/suppr.txt b/dockerfiles/ci/bookworm/php-8.5/suppr.txt new file mode 100644 index 00000000000..39c643abb53 --- /dev/null +++ b/dockerfiles/ci/bookworm/php-8.5/suppr.txt @@ -0,0 +1 @@ +leak:timer_create diff --git a/dockerfiles/ci/buster/docker-compose.yml b/dockerfiles/ci/buster/docker-compose.yml index dce6256f028..dc156d21214 100644 --- a/dockerfiles/ci/buster/docker-compose.yml +++ b/dockerfiles/ci/buster/docker-compose.yml @@ -9,6 +9,17 @@ services: - linux/arm64 - linux/amd64 + php-8.5: + image: datadog/dd-trace-ci:php-8.5_buster + build: + context: . + dockerfile: php-8.5/Dockerfile + x-bake: *bake + args: + phpVersion: "8.5" + phpTarGzUrl: https://downloads.php.net/~daniels/php-8.5.0RC1.tar.gz + phpSha256Hash: "0ea5059a387117fe6ed9a72cdc20945dbff6acc072df936e97d35a9cb26420e0" + php-8.4: image: datadog/dd-trace-ci:php-8.4_buster build: diff --git a/dockerfiles/ci/buster/php-8.5/Dockerfile b/dockerfiles/ci/buster/php-8.5/Dockerfile new file mode 100644 index 00000000000..551b6cf72ec --- /dev/null +++ b/dockerfiles/ci/buster/php-8.5/Dockerfile @@ -0,0 +1,90 @@ +FROM datadog/dd-trace-ci:buster AS base + +ARG phpVersion +ENV PHP_VERSION=${phpVersion} +ENV LSAN_OPTIONS="suppressions=/home/circleci/suppr.txt,print_suppressions=0" + +COPY php-8.5/suppr.txt /home/circleci/suppr.txt + +FROM --platform=$BUILDPLATFORM datadog/dd-trace-ci:buster AS src +ARG phpTarGzUrl +ARG phpSha256Hash +RUN set -eux; \ + curl -fsSL -o /tmp/php.tar.gz "${phpTarGzUrl}"; \ + (echo "${phpSha256Hash} /tmp/php.tar.gz" | sha256sum -c -); \ + tar xf /tmp/php.tar.gz -C "${PHP_SRC_DIR}" --strip-components=1; \ + rm -f /tmp/php.tar.gz; \ + cd ${PHP_SRC_DIR}; \ + # We need to remove the dl() calls from run-tests as some extensions don't properly switch interned string storage for INIs. \ + sed -i 's/\bdl(/(bool)(/' run-tests.php; \ + ./buildconf --force; + +FROM --platform=$BUILDPLATFORM datadog/dd-trace-ci:buster AS build +ARG phpVersion +ENV PHP_VERSION=${phpVersion} +ENV PHP_INSTALL_DIR=${PHP_INSTALL_DIR} +ARG TARGETPLATFORM +ARG BUILDPLATFORM +# install cross-compiling packages +RUN if [ "$BUILDPLATFORM" != "$TARGETPLATFORM" ]; then \ + sudo dpkg --add-architecture ${TARGETPLATFORM#linux/}; \ + sudo apt update; \ + sudo apt-get install -y --no-install-recommends valgrind:${TARGETPLATFORM#linux/} $(echo $DEVLIBS | sed "s/\(\s\|$\)/:${TARGETPLATFORM#linux/}\1/g"); \ + fi +COPY build-php.sh /home/circleci +COPY --chown=circleci:circleci --from=src $PHP_SRC_DIR $PHP_SRC_DIR + +FROM build AS php-debug +ARG TARGETPLATFORM +RUN /home/circleci/build-php.sh $TARGETPLATFORM $PHP_INSTALL_DIR debug $PHP_VERSION +COPY build-extensions.sh /home/circleci +RUN /home/circleci/build-extensions.sh + +FROM build AS php-nts +ARG TARGETPLATFORM +RUN /home/circleci/build-php.sh $TARGETPLATFORM $PHP_INSTALL_DIR nts $PHP_VERSION +COPY build-extensions.sh /home/circleci +RUN /home/circleci/build-extensions.sh + +FROM build AS php-zts +ARG TARGETPLATFORM +RUN /home/circleci/build-php.sh $TARGETPLATFORM $PHP_INSTALL_DIR zts $PHP_VERSION +COPY build-extensions.sh /home/circleci +RUN /home/circleci/build-extensions.sh + +FROM build AS php-debug-zts-asan +ARG TARGETPLATFORM +RUN /home/circleci/build-php.sh $TARGETPLATFORM $PHP_INSTALL_DIR debug-zts-asan $PHP_VERSION \ + && mv /tmp/build-php/sapi/cli/php /tmp/build-php/sapi/cli/php-asan +# for reasons the asan build just ... crashes in qemu (or executed via bytecode interpreter). The binary itself however perfectly works on the target platform +# just put a working php binary there to continue installation and be happy, then copy back later. +COPY --chown=circleci:circleci --from=php-debug $PHP_INSTALL_DIR/debug/bin/php /tmp/build-php/sapi/cli/php +RUN set -eux; ln -s $PHP_INSTALL_DIR/debug-zts-asan $PHP_INSTALL_DIR/debug; cd /tmp/build-php; touch sapi/cli/php; make install; switch-php debug-zts-asan; +COPY build-extensions.sh /home/circleci +RUN /home/circleci/build-extensions.sh +RUN cp /tmp/build-php/sapi/cli/php-asan $PHP_INSTALL_DIR/debug-zts-asan/bin/php + +FROM base AS final +COPY --chown=circleci:circleci --from=src $PHP_SRC_DIR $PHP_SRC_DIR +COPY --chown=circleci:circleci --from=php-debug-zts-asan $PHP_INSTALL_DIR/debug-zts-asan $PHP_INSTALL_DIR/debug-zts-asan +COPY --chown=circleci:circleci --from=php-debug $PHP_INSTALL_DIR/debug $PHP_INSTALL_DIR/debug +COPY --chown=circleci:circleci --from=php-nts $PHP_INSTALL_DIR/nts $PHP_INSTALL_DIR/nts +COPY --chown=circleci:circleci --from=php-zts $PHP_INSTALL_DIR/zts $PHP_INSTALL_DIR/zts + +USER root + +RUN set -eux; \ + # Enable the apache config \ + echo "LoadModule php_module /usr/lib/apache2/modules/libphp.so" | tee /etc/apache2/mods-enabled/php.load; \ + # Set the default PHP version + switch-php debug; + +# Install Composer +COPY --from=composer:2 /usr/bin/composer /usr/local/bin/composer + +COPY welcome /etc/motd +RUN sudo sed -i "s/VERSIONS/$(ls $PHP_INSTALL_DIR | xargs)/" /etc/motd + +USER circleci + +CMD ["php-fpm", "-F"] diff --git a/dockerfiles/ci/buster/php-8.5/suppr.txt b/dockerfiles/ci/buster/php-8.5/suppr.txt new file mode 100644 index 00000000000..39c643abb53 --- /dev/null +++ b/dockerfiles/ci/buster/php-8.5/suppr.txt @@ -0,0 +1 @@ +leak:timer_create diff --git a/dockerfiles/ci/centos/7/base.Dockerfile b/dockerfiles/ci/centos/7/base.Dockerfile index 185d2b55fd8..92b4b62b698 100644 --- a/dockerfiles/ci/centos/7/base.Dockerfile +++ b/dockerfiles/ci/centos/7/base.Dockerfile @@ -71,7 +71,7 @@ RUN source scl_source enable devtoolset-7; set -eux; \ ../configure && make -j $(nproc) && make install; \ cd - && rm -fr build -# Required: oniguruma (not installed by deafult) +# Required: oniguruma (not installed by default) RUN source scl_source enable devtoolset-7; set -eux; \ /root/download-src.sh oniguruma https://github.com/kkos/oniguruma/releases/download/v6.9.5_rev1/onig-6.9.5-rev1.tar.gz; \ cd "${SRC_DIR}/oniguruma"; \ @@ -79,7 +79,7 @@ RUN source scl_source enable devtoolset-7; set -eux; \ ../configure && make -j $(nproc) && make install; \ cd - && rm -fr build -# Required: bison >= 3.0.0 (not installed by deafult) +# Required: bison >= 3.0.0 (not installed by default) RUN source scl_source enable devtoolset-7; set -eux; \ /root/download-src.sh bison https://mirrors.kernel.org/gnu/bison/bison-3.7.3.tar.gz; \ cd "${SRC_DIR}/bison"; \ @@ -87,7 +87,7 @@ RUN source scl_source enable devtoolset-7; set -eux; \ ../configure && make -j $(nproc) && make install; \ cd - && rm -fr build -# Required: re2c >= 0.13.4 (not installed by deafult) +# Required: re2c >= 0.13.4 (not installed by default) RUN source scl_source enable devtoolset-7; set -eux; \ /root/download-src.sh re2c https://github.com/skvadrik/re2c/releases/download/2.0.3/re2c-2.0.3.tar.xz; \ cd "${SRC_DIR}/re2c"; \ @@ -96,7 +96,6 @@ RUN source scl_source enable devtoolset-7; set -eux; \ cd - && rm -fr build # Required: CMake >= 3.20.0 (default version is 2.8.12.2) -# Required to build libzip from source (has to be a separate RUN layer) RUN source scl_source enable devtoolset-7; set -eux; \ /root/download-src.sh cmake https://github.com/Kitware/CMake/releases/download/v3.28.6/cmake-3.28.6.tar.gz; \ cd "${SRC_DIR}/cmake"; \ @@ -112,16 +111,7 @@ RUN set -eux; \ cmake --build build/ --target install; \ cd - && rm -fr build - -# Required: libzip >= 0.11 (default version is 0.9) -RUN source scl_source enable devtoolset-7; set -eux; \ - /root/download-src.sh libzip https://libzip.org/download/libzip-1.7.3.tar.gz; \ - cd "${SRC_DIR}/libzip"; \ - mkdir build && cd build; \ - cmake .. && make -j $(nproc) && make install; \ - cd - && rm -fr build - -# PHP 8.4 requires OpenSSL >= 1.1.1 +# PHP 8.4+ requires OpenSSL >= 1.1.1 RUN source scl_source enable devtoolset-7; set -ex; \ /root/download-src.sh openssl https://openssl.org/source/old/1.1.1/openssl-1.1.1w.tar.gz; \ cd "${SRC_DIR}/openssl"; \ @@ -143,12 +133,29 @@ RUN source scl_source enable devtoolset-7; set -ex; \ make -j $(nproc) && make install; \ cd - && rm -fr build -# PHP 8.4 requires curl >= 7.61.0 +RUN source scl_source enable devtoolset-7; set -eux; \ + /root/download-src.sh libzip https://libzip.org/download/libzip-1.10.1.tar.gz; \ + cd "${SRC_DIR}/libzip"; \ + rm -rf build && mkdir build && cd build; \ + cmake .. \ + -DCMAKE_INSTALL_PREFIX=/usr/local \ + -DBUILD_SHARED_LIBS=ON \ + -DENABLE_OPENSSL=ON \ + -DCMAKE_PREFIX_PATH="/usr/local/openssl;/usr/local/zlib" \ + -DOpenSSL_ROOT=/usr/local/openssl \ + -DZLIB_ROOT=/usr/local/zlib \ + -DCMAKE_POLICY_DEFAULT_CMP0074=NEW \ + -DCMAKE_INSTALL_RPATH=/usr/local/openssl/lib; \ + make -j $(nproc) && make install; \ + ldconfig; \ + cd - && rm -fr build + +# PHP 8.4 requires curl >= 7.61.0 (link it to OpenSSL 1.1.1 we just built) RUN source scl_source enable devtoolset-7; set -ex; \ /root/download-src.sh curl https://curl.se/download/curl-7.61.1.tar.gz; \ cd "${SRC_DIR}/curl"; \ mkdir -v 'build' && cd 'build'; \ - ../configure --prefix=/usr/local/curl; \ + ../configure --prefix=/usr/local/curl --with-ssl=/usr/local/openssl; \ make -j $(nproc) && make install; \ cd - && rm -fr build @@ -165,10 +172,6 @@ ENV PKG_CONFIG_PATH="${PKG_CONFIG_PATH}:/usr/local/lib/pkgconfig:/usr/local/lib6 # Caution, takes a very long time! Since we have to build one from source, # I picked LLVM 17, which matches Rust 1.76. -# Ordinarily we leave sources, but LLVM is 2GiB just for the sources... -# Minimum: libclang. Nice-to-have: full toolchain including linker to play -# with cross-language link-time optimization. Needs to match rustc -Vv's llvm -# version. RUN source scl_source enable devtoolset-9 \ && yum install -y python3 \ && /root/download-src.sh ninja https://github.com/ninja-build/ninja/archive/refs/tags/v1.11.0.tar.gz \ @@ -214,7 +217,6 @@ RUN source scl_source enable devtoolset-7 \ ARG RUST_VERSION="1.84.1" ARG RUST_SHA256_ARM="be89f6ad9b70cc4b25182ae299f94ab047a713a51fddf95284823c8afe4aef85" ARG RUST_SHA256_X86="106c89f23ce1c763fcbea8e2714b2ba869bf7af70804813987a4483896398933" -# Mount a cache into /rust/cargo if you want to pre-fetch packages or something ENV CARGO_HOME=/rust/cargo ENV RUSTUP_HOME=/rust/rustup RUN source scl_source enable devtoolset-7 \ @@ -255,5 +257,6 @@ RUN printf "source scl_source enable devtoolset-7" | tee -a /etc/profile.d/zzz-d ENV BASH_ENV="/etc/profile.d/zzz-ddtrace.sh" ENV PATH="/rust/cargo/bin:${PATH}" +ENV LD_LIBRARY_PATH="/usr/local/openssl/lib:${LD_LIBRARY_PATH}" RUN echo '#define SECBIT_NO_SETUID_FIXUP (1 << 2)' > '/usr/include/linux/securebits.h' diff --git a/dockerfiles/ci/centos/7/docker-compose.yml b/dockerfiles/ci/centos/7/docker-compose.yml index 60b28a65407..1a9e9605a56 100644 --- a/dockerfiles/ci/centos/7/docker-compose.yml +++ b/dockerfiles/ci/centos/7/docker-compose.yml @@ -120,3 +120,14 @@ services: phpTarGzUrl: https://www.php.net/distributions/php-8.4.1.tar.gz phpSha256Hash: "c3d1ce4157463ea43004289c01172deb54ce9c5894d8722f4e805461bf9feaec" image: 'datadog/dd-trace-ci:php-8.4_centos-7' + + php-8.5: + build: + context: . + dockerfile: php.Dockerfile + x-bake: *bake + args: + phpVersion: "8.5" + phpTarGzUrl: https://downloads.php.net/~daniels/php-8.5.0RC1.tar.gz + phpSha256Hash: "0ea5059a387117fe6ed9a72cdc20945dbff6acc072df936e97d35a9cb26420e0" + image: 'datadog/dd-trace-ci:php-8.5_centos-7' diff --git a/dockerfiles/ci/centos/7/php-8.5/configure.sh b/dockerfiles/ci/centos/7/php-8.5/configure.sh new file mode 100755 index 00000000000..6f925107ef8 --- /dev/null +++ b/dockerfiles/ci/centos/7/php-8.5/configure.sh @@ -0,0 +1,50 @@ +#!/usr/bin/env bash + +if [ -z "${PHP_SRC_DIR}" ]; then + echo "Please set PHP_SRC_DIR" + exit 1 +fi + +# needed for CentOS7 vs PHP 8.3 on amd64, otherwise you get a: +# ld: dynamic STT_GNU_IFUNC symbol `mb_wchar_to_utf16le' with pointer equality in `ext/mbstring/libmbfl/filters/mbfilter_utf16.o' can not be used when making an executable; recompile with -fPIE and relink with -pie +# see also https://github.com/php/php-src/issues/11603 +if [ "$(uname -m)" = "x86_64" ]; then + export LDFLAGS=-pie + export CFLAGS=-fPIE +fi + +${PHP_SRC_DIR}/configure \ + --enable-option-checking=fatal \ + --enable-calendar \ + --enable-cgi \ + --enable-exif \ + --enable-fpm \ + --enable-ftp \ + --enable-mbstring \ + --enable-mysqlnd \ + --enable-phpdbg \ + --enable-pcntl \ + --enable-shmop \ + --enable-sockets \ + --enable-sysvmsg \ + --enable-sysvsem \ + --enable-sysvshm \ + --with-apxs2 \ + --with-bz2 \ + --with-curl \ + --with-ffi \ + --with-fpm-user=www-data \ + --with-fpm-group=www-data \ + --with-libedit \ + --with-mhash \ + --with-mysqli=mysqlnd \ + --with-gettext \ + --with-openssl \ + --with-pdo-mysql=mysqlnd \ + --with-pear \ + --with-readline \ + --with-sodium \ + --with-xsl \ + --with-zip \ + --with-zlib \ + $@ diff --git a/dockerfiles/ci/centos/7/php.Dockerfile b/dockerfiles/ci/centos/7/php.Dockerfile index 57162c8d52b..755cb1972f1 100644 --- a/dockerfiles/ci/centos/7/php.Dockerfile +++ b/dockerfiles/ci/centos/7/php.Dockerfile @@ -29,21 +29,32 @@ COPY php-${PHP_VERSION}/configure.sh /root/ FROM base AS php-zts RUN bash -c 'set -eux; \ + if [ "$(uname -m)" = "aarch64" ]; then \ + export CFLAGS="${CFLAGS:-} -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0"; \ + export CPPFLAGS="${CPPFLAGS:-} -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0"; \ + fi; \ mkdir -p /tmp/build-php && cd /tmp/build-php \ && /root/configure.sh \ --enable-$(if [ $(expr substr ${PHP_VERSION} 1 1) = 7 ]; then echo maintainer-; fi)zts \ --prefix=${PHP_INSTALL_DIR_ZTS} \ --with-config-file-path=${PHP_INSTALL_DIR_ZTS} \ --with-config-file-scan-dir=${PHP_INSTALL_DIR_ZTS}/conf.d \ + $(if [ "$(expr substr ${PHP_VERSION} 1 1)" -eq 8 ] && [ "$(expr substr ${PHP_VERSION} 3 1)" -ge 5 ]; then \ + echo "ax_cv_have_func_attribute_ifunc=no"; \ + fi) \ && make -j 2 \ && make install \ && cp .libs/libphp*.so ${PHP_INSTALL_DIR_ZTS}/lib/apache2handler-libphp.so \ && mkdir -p ${PHP_INSTALL_DIR_ZTS}/conf.d' \ - && [ $(expr substr ${PHP_VERSION} 1 1) = 7 ] || ${PHP_INSTALL_DIR_ZTS}/bin/pecl install parallel \ - && [ $(expr substr ${PHP_VERSION} 1 1) = 7 ] || echo "extension=parallel" >> ${PHP_INSTALL_DIR_ZTS}/conf.d/parallel.ini + && [ $(expr substr ${PHP_VERSION} 1 1) = 7 ] || ${PHP_INSTALL_DIR_ZTS}/bin/pecl install parallel || true \ + && [ $(expr substr ${PHP_VERSION} 1 1) = 7 ] || echo "extension=parallel" >> ${PHP_INSTALL_DIR_ZTS}/conf.d/parallel.ini || true FROM base AS php-debug RUN bash -c 'set -eux; \ + if [ "$(uname -m)" = "aarch64" ]; then \ + export CFLAGS="${CFLAGS:-} -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0"; \ + export CPPFLAGS="${CPPFLAGS:-} -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0"; \ + fi; \ mkdir -p /tmp/build-php && cd /tmp/build-php \ && /root/configure.sh \ --enable-debug \ @@ -57,6 +68,10 @@ RUN bash -c 'set -eux; \ FROM base AS php-nts RUN bash -c 'set -eux; \ + if [ "$(uname -m)" = "aarch64" ]; then \ + export CFLAGS="${CFLAGS:-} -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0"; \ + export CPPFLAGS="${CPPFLAGS:-} -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0"; \ + fi; \ mkdir -p /tmp/build-php && cd /tmp/build-php \ && /root/configure.sh \ --prefix=${PHP_INSTALL_DIR_NTS} \ diff --git a/dockerfiles/ci/windows/Dockerfile b/dockerfiles/ci/windows/Dockerfile index 12df27bb72d..d3b7a1c4858 100644 --- a/dockerfiles/ci/windows/Dockerfile +++ b/dockerfiles/ci/windows/Dockerfile @@ -26,7 +26,7 @@ FROM base AS php-zts ENV THREAD_SAFE=1 RUN build_php.bat -FROM base as final +FROM base AS final COPY --chown=circleci:circleci --from=php-nts /php /php-nts COPY --chown=circleci:circleci --from=php-zts /php /php-zts diff --git a/dockerfiles/ci/windows/docker-compose.yml b/dockerfiles/ci/windows/docker-compose.yml index 313e73efa66..ea556fc911c 100644 --- a/dockerfiles/ci/windows/docker-compose.yml +++ b/dockerfiles/ci/windows/docker-compose.yml @@ -78,6 +78,18 @@ services: vsVersion: "vs17" sdkVersion: "2.3.0" + php-8.5: + image: datadog/dd-trace-ci:php-8.5_windows + build: + platforms: + - windows/amd64 + context: . + args: + phpVersion: "8.5.0" + vsVersion: "vs17" + phpTarGzUrl: https://downloads.php.net/~daniels/php-8.5.0RC1.tar.gz + phpSha256Hash: "0ea5059a387117fe6ed9a72cdc20945dbff6acc072df936e97d35a9cb26420e0" + php-8.4: image: datadog/dd-trace-ci:php-8.4_windows build: diff --git a/dockerfiles/ci/xfail_tests/8.5.list b/dockerfiles/ci/xfail_tests/8.5.list new file mode 100644 index 00000000000..4f3c4b68b25 --- /dev/null +++ b/dockerfiles/ci/xfail_tests/8.5.list @@ -0,0 +1,219 @@ +Zend/tests/014.phpt +Zend/tests/arginfo_zpp_mismatch.phpt +Zend/tests/arginfo_zpp_mismatch_strict.phpt +Zend/tests/bug63882_2.phpt +Zend/tests/bug69315.phpt +Zend/tests/bug70258.phpt +Zend/tests/bug70805.phpt +Zend/tests/bug70805_1.phpt +Zend/tests/bug70805_2.phpt +Zend/tests/bug71539_5.phpt +Zend/tests/bug72038.phpt +Zend/tests/bug75921.phpt +Zend/tests/bug78182.phpt +Zend/tests/bug81104.phpt +Zend/tests/fibers/gh10496-001.phpt +Zend/tests/fibers/destructors_005.phpt +Zend/tests/fibers/out-of-memory-in-fiber.phpt +Zend/tests/fibers/out-of-memory-in-nested-fiber.phpt +Zend/tests/fibers/out-of-memory-in-recursive-fiber.phpt +Zend/tests/gc_031.phpt +Zend/tests/gc_037.phpt +Zend/tests/gc_045.phpt +Zend/tests/get_defined_functions_basic.phpt +Zend/tests/get_required_files.phpt +Zend/tests/gh7958.phpt +Zend/tests/gh10346.phpt +Zend/tests/gh11189.phpt +Zend/tests/gh11189_1.phpt +Zend/tests/gh12073.phpt +Zend/tests/list_keyed_conversions.phpt +Zend/tests/multibyte/multibyte_encoding_004.phpt +Zend/tests/object_gc_in_shutdown.phpt +Zend/tests/offset_array.phpt +Zend/tests/stack_limit/stack_limit_013.phpt +Zend/tests/strict_001.phpt +Zend/tests/type_declarations/scalar_return_basic_64bit.phpt +Zend/tests/type_declarations/scalar_strict_64bit.phpt +Zend/tests/weakrefs/gh10043-007.phpt +Zend/tests/weakrefs/weakmap_basic_map_behavior.phpt +Zend/tests/weakrefs/weakmap_error_conditions.phpt +ext/curl/tests/bug45161.phpt +ext/curl/tests/bug64267.phpt +ext/curl/tests/bug76675.phpt +ext/curl/tests/bug77535.phpt +ext/curl/tests/bug79033.phpt +ext/curl/tests/curl_int_cast.phpt +ext/curl/tests/curl_postfields_array.phpt +ext/curl/tests/curl_setopt_CURLOPT_ACCEPT_ENCODING.phpt +ext/curl/tests/curl_setopt_CURLOPT_DEBUGFUNCTION.phpt +ext/curl/tests/curl_upkeep_001.phpt +ext/date/tests/bug52113.phpt +ext/dom/tests/dom_set_attr_node.phpt +ext/dom/tests/dom003.phpt +ext/dom/tests/modern/xml/XMLDocument_xpath_errors.phpt +ext/fileinfo/tests/finfo_open_error.phpt +ext/json/tests/json_decode_exceptions.phpt +ext/json/tests/json_encode_exceptions.phpt +ext/mbstring/tests/zend_multibyte-01.phpt +ext/mbstring/tests/zend_multibyte-02.phpt +ext/mbstring/tests/zend_multibyte-06.phpt +ext/opcache/tests/jit/fetch_obj_001.phpt +ext/openssl/tests/bug46127.phpt +ext/openssl/tests/bug48182.phpt +ext/openssl/tests/bug54992.phpt +ext/openssl/tests/bug65538_001.phpt +ext/openssl/tests/bug65538_003.phpt +ext/openssl/tests/bug65729.phpt +ext/openssl/tests/bug68265.phpt +ext/openssl/tests/bug68879.phpt +ext/openssl/tests/bug68920.phpt +ext/openssl/tests/bug69215.phpt +ext/openssl/tests/bug72333.phpt +ext/openssl/tests/bug74159.phpt +ext/openssl/tests/bug77390.phpt +ext/openssl/tests/capture_peer_cert_001.phpt +ext/openssl/tests/openssl_encrypt_ccm.phpt +ext/openssl/tests/openssl_peer_fingerprint_basic.phpt +ext/openssl/tests/openssl_x509_checkpurpose_basic.phpt +ext/openssl/tests/peer_verification.phpt +ext/openssl/tests/san_peer_matching.phpt +ext/openssl/tests/session_meta_capture.phpt +ext/openssl/tests/session_meta_capture_tlsv13.phpt +ext/openssl/tests/stream_crypto_flags_001.phpt +ext/openssl/tests/stream_crypto_flags_002.phpt +ext/openssl/tests/stream_crypto_flags_003.phpt +ext/openssl/tests/stream_crypto_flags_004.phpt +ext/openssl/tests/stream_security_level.phpt +ext/openssl/tests/stream_server_reneg_limit.phpt +ext/openssl/tests/stream_verify_peer_name_001.phpt +ext/openssl/tests/stream_verify_peer_name_002.phpt +ext/openssl/tests/stream_verify_peer_name_003.phpt +ext/openssl/tests/streams_crypto_method.phpt +ext/openssl/tests/tls_min_v1.0_max_v1.1_wrapper.phpt +ext/openssl/tests/tls_wrapper.phpt +ext/openssl/tests/tls_wrapper_with_tls_v1.3.phpt +ext/openssl/tests/tlsv1.0_wrapper.phpt +ext/openssl/tests/tlsv1.1_wrapper.phpt +ext/openssl/tests/tlsv1.2_wrapper.phpt +ext/openssl/tests/tlsv1.3_wrapper.phpt +ext/pcntl/tests/pcntl_unshare_01.phpt +ext/pcntl/tests/pcntl_unshare_02.phpt +ext/pcntl/tests/pcntl_unshare_03.phpt +ext/pcntl/tests/pcntl_cpuaffinity.phpt +ext/pcntl/tests/pcntl_getcpu.phpt +ext/pcntl/tests/pcntl_setns_basic.phpt +ext/pdo/tests/pdo_023.phpt +ext/pdo/tests/pdo_030.phpt +ext/pdo_sqlite/tests/bug43831.phpt +ext/pdo_sqlite/tests/bug44327_2.phpt +ext/pdo_sqlite/tests/bug44327_3.phpt +ext/pdo_sqlite/tests/bug48773.phpt +ext/pdo_sqlite/tests/pdo_fetch_func_001.phpt +ext/pdo_sqlite/tests/pdo_sqlite_lastinsertid.phpt +ext/phar/tests/031.phpt +ext/phar/tests/032.phpt +ext/phar/tests/fatal_error_webphar.phpt +ext/phar/tests/phar_buildfromiterator10.phpt +ext/phar/tests/phar_buildfromiterator8.phpt +ext/phar/tests/phar_metadata_write4.phpt +ext/phar/tests/phar_oo_002.phpt +ext/phar/tests/phar_oo_005.phpt +ext/phar/tests/phar_oo_007.phpt +ext/readline/tests/libedit_callback_handler_install_001.phpt +ext/readline/tests/libedit_callback_handler_remove_001.phpt +ext/simplexml/tests/bug51615.phpt +ext/soap/tests/bugs/bug77088.phpt +ext/sockets/tests/socket_create_listen-nobind.phpt +ext/sockets/tests/socket_import_stream-4.phpt +ext/spl/tests/bug40091.phpt +ext/spl/tests/bug44144.phpt +ext/spl/tests/bug48493.phpt +ext/spl/tests/bug62978.phpt +ext/spl/tests/bug65006.phpt +ext/spl/tests/bug71236.phpt +ext/spl/tests/bug75049.phpt +ext/spl/tests/fixedarray_003.phpt +ext/spl/tests/gh8318.phpt +ext/spl/tests/gh10011.phpt +ext/spl/tests/spl_autoload_002.phpt +ext/spl/tests/spl_autoload_004.phpt +ext/spl/tests/spl_autoload_006.phpt +ext/spl/tests/spl_autoload_008.phpt +ext/spl/tests/spl_autoload_013.phpt +ext/standard/tests/array/array_map_variation4.phpt +ext/standard/tests/array/array_reverse_variation4.phpt +ext/standard/tests/array/array_unique_variation3.phpt +ext/standard/tests/file/bug52820.phpt +ext/standard/tests/file/disk_free_space_basic.phpt +ext/standard/tests/file/file_get_contents_file_put_contents_5gb.phpt +ext/standard/tests/file/lstat_stat_variation10.phpt +ext/standard/tests/file/lstat_stat_variation15.phpt +ext/standard/tests/filters/bug54350.phpt +ext/standard/tests/general_functions/bug73973.phpt +ext/standard/tests/general_functions/floatval.phpt +ext/standard/tests/general_functions/floatval_variation1.phpt +ext/standard/tests/general_functions/get_included_files.phpt +ext/standard/tests/general_functions/gettype_settype_basic.phpt +ext/standard/tests/general_functions/print_r.phpt +ext/standard/tests/general_functions/print_r_64bit.phpt +ext/standard/tests/general_functions/proc_open_null.phpt +ext/standard/tests/general_functions/proc_open_redirect.phpt +ext/standard/tests/general_functions/strval.phpt +ext/standard/tests/general_functions/type.phpt +ext/standard/tests/general_functions/var_dump_64bit.phpt +ext/standard/tests/gh14643_longname.phpt +ext/standard/tests/math/base_convert_variation1.phpt +ext/standard/tests/math/bindec_variation1_64bit.phpt +ext/standard/tests/math/hexdec_variation1_64bit.phpt +ext/standard/tests/math/octdec_variation1.phpt +ext/standard/tests/network/bug80067.phpt +ext/standard/tests/network/syslog_new_line.phpt +ext/standard/tests/network/syslog_null_byte.phpt +ext/standard/tests/serialize/005.phpt +ext/standard/tests/streams/bug78902.phpt +ext/standard/tests/streams/proc_open_bug69900.phpt +ext/standard/tests/streams/stream_context_tcp_nodelay_fopen.phpt +ext/standard/tests/strings/gh15613.phpt +ext/standard/tests/strings/sprintf_variation54.phpt +ext/zend_test/tests/ +sapi/cli/tests/bug80092.phpt +sapi/cli/tests/gh8827-001.phpt +sapi/cli/tests/gh8827-003.phpt +sapi/cli/tests/upload_2G.phpt +sapi/fpm/tests/log-bm-in-shutdown-fn.phpt +sapi/fpm/tests/log-bm-limit-1024-msg-80.phpt +sapi/fpm/tests/log-bm-limit-2048-msg-4000.phpt +sapi/fpm/tests/log-bwd-limit-1050-msg-2048.phpt +sapi/fpm/tests/log-bwd-limit-1050-msg-2900.phpt +sapi/fpm/tests/log-bwd-limit-8000-msg-4096.phpt +sapi/fpm/tests/log-bwd-msg-with-nl.phpt +sapi/fpm/tests/log-bwp-limit-1024-msg-120.phpt +sapi/fpm/tests/log-bwp-limit-1500-msg-3300.phpt +sapi/fpm/tests/log-bwp-msg-flush-split-fallback.phpt +sapi/fpm/tests/log-bwp-msg-flush-split-real.phpt +sapi/fpm/tests/log-dwd-limit-1050-msg-2048.phpt +sapi/fpm/tests/log-dwd-limit-1050-msg-2900.phpt +sapi/fpm/tests/log-dwd-limit-8000-msg-4096.phpt +sapi/fpm/tests/log-dwp-limit-1000-msg-2000.phpt +sapi/phpdbg/tests/exceptions_003.phpt +sapi/phpdbg/tests/stepping_001.phpt +tests/lang/bug45392.phpt +tests/output/ob_start_basic_002.phpt +tests/output/stream_isatty_err.phpt +tests/output/stream_isatty_in-err.phpt +tests/output/stream_isatty_in-out.phpt +tests/output/stream_isatty_out-err.phpt +tests/output/stream_isatty_out.phpt +ext/standard/tests/http/bug67430.phpt +ext/standard/tests/http/bug61548.phpt +ext/standard/tests/http/bug53198.phpt +ext/standard/tests/http/bug48929.phpt +ext/standard/tests/http/bug38802.phpt +ext/standard/tests/http/bug65634.phpt +ext/standard/tests/http/bug79265.phpt +ext/standard/tests/http/bug79265_2.phpt +ext/standard/tests/http/ghsa-hgf5-96fm-v528-003.phpt +ext/standard/tests/http/ghsa-hgf5-96fm-v528-002.phpt +ext/standard/tests/http/ghsa-hgf5-96fm-v528-001.phpt +ext/standard/tests/http/ignore_errors.phpt diff --git a/dockerfiles/testing-environment/Wordpress5/app/wp-includes/Requests/Transport/cURL.php b/dockerfiles/testing-environment/Wordpress5/app/wp-includes/Requests/Transport/cURL.php index 4429edb6473..7adac85816f 100644 --- a/dockerfiles/testing-environment/Wordpress5/app/wp-includes/Requests/Transport/cURL.php +++ b/dockerfiles/testing-environment/Wordpress5/app/wp-includes/Requests/Transport/cURL.php @@ -112,7 +112,7 @@ public function __construct() { */ public function __destruct() { if (is_resource($this->handle)) { - curl_close($this->handle); + if (PHP_VERSION_ID < 80000) { curl_close($this->handle); } } } @@ -254,7 +254,7 @@ public function request_multiple($requests, $options) { } curl_multi_remove_handle($multihandle, $done['handle']); - curl_close($done['handle']); + if (PHP_VERSION_ID < 80000) { curl_close($done['handle']); } if (!is_string($responses[$key])) { $options['hooks']->dispatch('multiple.request.complete', array(&$responses[$key], $key)); diff --git a/dockerfiles/testing-environment/Wordpress5/app/wp-includes/SimplePie/File.php b/dockerfiles/testing-environment/Wordpress5/app/wp-includes/SimplePie/File.php index b7d1a2ac9b6..433720273b7 100644 --- a/dockerfiles/testing-environment/Wordpress5/app/wp-includes/SimplePie/File.php +++ b/dockerfiles/testing-environment/Wordpress5/app/wp-includes/SimplePie/File.php @@ -127,7 +127,7 @@ public function __construct($url, $timeout = 10, $redirects = 5, $headers = null else { $info = curl_getinfo($fp); - curl_close($fp); + if (PHP_VERSION_ID < 80000) { curl_close($fp); } $this->headers = explode("\r\n\r\n", $this->headers, $info['redirect_count'] + 1); $this->headers = array_pop($this->headers); $parser = new SimplePie_HTTP_Parser($this->headers); diff --git a/dockerfiles/testing-environment/Wordpress5/app/wp-includes/class-wp-http-curl.php b/dockerfiles/testing-environment/Wordpress5/app/wp-includes/class-wp-http-curl.php index 8225a290f4c..8256fb4dd7d 100644 --- a/dockerfiles/testing-environment/Wordpress5/app/wp-includes/class-wp-http-curl.php +++ b/dockerfiles/testing-environment/Wordpress5/app/wp-includes/class-wp-http-curl.php @@ -235,15 +235,15 @@ public function request( $url, $args = array() ) { $curl_error = curl_error( $handle ); if ( $curl_error ) { - curl_close( $handle ); + if (PHP_VERSION_ID < 80000) { curl_close( $handle ); } return new WP_Error( 'http_request_failed', $curl_error ); } if ( in_array( curl_getinfo( $handle, CURLINFO_HTTP_CODE ), array( 301, 302 ) ) ) { - curl_close( $handle ); + if (PHP_VERSION_ID < 80000) { curl_close( $handle ); } return new WP_Error( 'http_request_failed', __( 'Too many redirects.' ) ); } - curl_close( $handle ); + if (PHP_VERSION_ID < 80000) { curl_close( $handle ); } return array( 'headers' => array(), 'body' => '', @@ -271,28 +271,28 @@ public function request( $url, $args = array() ) { if ( CURLE_WRITE_ERROR /* 23 */ == $curl_error ) { if ( ! $this->max_body_length || $this->max_body_length != $bytes_written_total ) { if ( $parsed_args['stream'] ) { - curl_close( $handle ); + if (PHP_VERSION_ID < 80000) { curl_close( $handle ); } fclose( $this->stream_handle ); return new WP_Error( 'http_request_failed', __( 'Failed to write request to temporary file.' ) ); } else { - curl_close( $handle ); + if (PHP_VERSION_ID < 80000) { curl_close( $handle ); } return new WP_Error( 'http_request_failed', curl_error( $handle ) ); } } } else { $curl_error = curl_error( $handle ); if ( $curl_error ) { - curl_close( $handle ); + if (PHP_VERSION_ID < 80000) { curl_close( $handle ); } return new WP_Error( 'http_request_failed', $curl_error ); } } if ( in_array( curl_getinfo( $handle, CURLINFO_HTTP_CODE ), array( 301, 302 ) ) ) { - curl_close( $handle ); + if (PHP_VERSION_ID < 80000) { curl_close( $handle ); } return new WP_Error( 'http_request_failed', __( 'Too many redirects.' ) ); } } - curl_close( $handle ); + if (PHP_VERSION_ID < 80000) { curl_close( $handle ); } if ( $parsed_args['stream'] ) { fclose( $this->stream_handle ); diff --git a/examples/long-running/long-running-script.php b/examples/long-running/long-running-script.php index 5067f304e9d..4413d64bac9 100644 --- a/examples/long-running/long-running-script.php +++ b/examples/long-running/long-running-script.php @@ -24,7 +24,7 @@ function repetitive_function() curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $output = curl_exec($ch); error_log('Received response: ' . var_export($output, 1)); - curl_close($ch); + if (PHP_VERSION_ID < 80000) { curl_close($ch); } } $count = 0; diff --git a/loader/dd_library_loader.c b/loader/dd_library_loader.c index b66702581b7..5e7d52f51b4 100644 --- a/loader/dd_library_loader.c +++ b/loader/dd_library_loader.c @@ -16,7 +16,7 @@ #include "php_dd_library_loader.h" #define MIN_API_VERSION 320151012 -#define MAX_API_VERSION 420240924 +#define MAX_API_VERSION 420250925 #define MAX_INI_API_VERSION MAX_API_VERSION + 1 #define PHP_70_VERSION 20151012 @@ -25,7 +25,7 @@ #define PHP_80_VERSION 20200930 #define MIN_PHP_VERSION "7.0" -#define MAX_PHP_VERSION "8.4" +#define MAX_PHP_VERSION "8.5" extern zend_module_entry dd_library_loader_mod; diff --git a/loader/tests/functional/includes/autoload.php b/loader/tests/functional/includes/autoload.php index 56d987f6109..df8820e89f2 100644 --- a/loader/tests/functional/includes/autoload.php +++ b/loader/tests/functional/includes/autoload.php @@ -129,3 +129,10 @@ function skip_if_opcache_missing() { exit(0); } } + +function skip_if_over_php85() { + if (PHP_MAJOR_VERSION >= 8 && PHP_MINOR_VERSION >= 5) { + echo "Skip: test is not compatible with PHP 8.5+\n"; + exit(0); + } +} diff --git a/loader/tests/functional/test_opcache.php b/loader/tests/functional/test_opcache.php index afbc6cd2688..5bd4a58a7dd 100644 --- a/loader/tests/functional/test_opcache.php +++ b/loader/tests/functional/test_opcache.php @@ -2,6 +2,7 @@ require_once __DIR__."/includes/autoload.php"; skip_if_php5(); +skip_if_over_php85(); skip_if_opcache_missing(); $output = runCLI(__DIR__.'/fixtures/opcache.php'); diff --git a/package.xml b/package.xml index 75c89c47a99..b6a0b9bd3e4 100644 --- a/package.xml +++ b/package.xml @@ -92,7 +92,7 @@ ${changelog} 7.0 - 8.4.99 + 8.5.99 1.4.0 diff --git a/profiling/build.rs b/profiling/build.rs index 6eac9e911e8..c49381a35a2 100644 --- a/profiling/build.rs +++ b/profiling/build.rs @@ -412,24 +412,65 @@ fn cfg_zts() { println!("cargo::rustc-check-cfg=cfg(php_zts)"); } - let output = Command::new("php") - .arg("-n") - .arg("-r") - .arg("echo PHP_ZTS, PHP_EOL;") + let output = Command::new("php-config") + .arg("--include-dir") .output() - .expect("Unable to run `php`. Is it in your PATH?"); + .expect("Unable to run `php-config`. Is it in your PATH?"); if !output.status.success() { match String::from_utf8(output.stderr) { - Ok(stderr) => panic!("`php failed: {stderr}"), - Err(err) => panic!("`php` failed, not utf8: {err}"), + Ok(stderr) => panic!("`php-config --include-dir` failed: {stderr}"), + Err(err) => panic!("`php-config --include-dir` failed, not utf8: {err}"), } } - let zts = - std::str::from_utf8(output.stdout.as_slice()).expect("`php`'s stdout to be valid utf8"); + let include_dir = std::str::from_utf8(output.stdout.as_slice()) + .expect("`php-config`'s stdout to be valid utf8") + .trim(); + + // Create a temporary C file to probe ZTS + let out_dir = env::var("OUT_DIR").unwrap(); + let probe_path = Path::new(&out_dir).join("zts_probe.c"); + fs::write(&probe_path, r#" +#include "main/php_config.h" +#include +int main() { +#ifdef ZTS + printf("1"); +#else + printf("0"); +#endif + return 0; +} +"#).expect("Failed to write ZTS probe file"); + + // Get the C compiler from cc crate + let compiler = cc::Build::new().get_compiler(); + + // Compile the probe to an executable + let probe_exe = Path::new(&out_dir).join("zts_probe"); + let compile_status = Command::new(compiler.path()) + .arg(format!("-I{}", include_dir)) + .arg(&probe_path) + .arg("-o") + .arg(&probe_exe) + .status() + .expect("Failed to compile ZTS probe"); + + if !compile_status.success() { + panic!("Failed to compile ZTS probe"); + } + + // Run the probe + let probe_output = Command::new(&probe_exe) + .output() + .expect("Failed to run ZTS probe"); + + let zts_value = std::str::from_utf8(&probe_output.stdout) + .expect("ZTS probe output not UTF-8") + .trim(); - if zts.contains('1') { + if zts_value == "1" { println!("cargo:rustc-cfg=php_zts"); } } diff --git a/tea/src/exceptions.c b/tea/src/exceptions.c index 205c027fb32..b8c3dfdb415 100644 --- a/tea/src/exceptions.c +++ b/tea/src/exceptions.c @@ -1,7 +1,11 @@ #include zend_class_entry *tea_exception_throw(const char *message) { +#if PHP_VERSION_ID >= 80500 + zend_class_entry *ce = zend_ce_exception; +#else zend_class_entry *ce = zend_exception_get_default(); +#endif zend_throw_exception(ce, (char *)message, 0); return ce; } diff --git a/tests/C2PHP/get_context_distributed_tracing_test.phpt b/tests/C2PHP/get_context_distributed_tracing_test.phpt index 2db283cc6f2..d8143c39b2f 100644 --- a/tests/C2PHP/get_context_distributed_tracing_test.phpt +++ b/tests/C2PHP/get_context_distributed_tracing_test.phpt @@ -28,7 +28,7 @@ if (empty($response['headers']['X-Datadog-Origin']) || $response['headers']['X-D throw new Exception('Unexpected origin header. ' . var_export($response, true)); } -curl_close($ch); +if (PHP_VERSION_ID < 80000) { curl_close($ch); } var_dump($context->origin); echo "OK\n"; diff --git a/tests/Common/TracerTestTrait.php b/tests/Common/TracerTestTrait.php index 3a87b25eff0..6240b1f16d3 100644 --- a/tests/Common/TracerTestTrait.php +++ b/tests/Common/TracerTestTrait.php @@ -111,7 +111,7 @@ public function sendTracesToTestAgent($traces) $response = self::curlWithoutSpan($curl); // Close the cURL session - curl_close($curl); + if (PHP_VERSION_ID < 80000) { curl_close($curl); } // Output the response for debugging purposes //echo $response; @@ -201,7 +201,7 @@ public function inWebServer($fn, $rootPath, $envs = [], $inis = [], &$curlInfo = if (\is_array($curlInfo)) { $curlInfo = \array_merge($curlInfo, \curl_getinfo($curl)); } - \curl_close($curl); + if (PHP_VERSION_ID < 80000) { curl_close($curl); } $webServer->stop(); return $response; } diff --git a/tests/Common/WebFrameworkTestCase.php b/tests/Common/WebFrameworkTestCase.php index 2d971c49f03..022e6330d06 100644 --- a/tests/Common/WebFrameworkTestCase.php +++ b/tests/Common/WebFrameworkTestCase.php @@ -262,7 +262,7 @@ protected function sendRequest($method, $url, $headers = [], $body = [], $change } $response = curl_exec($ch); if ($response === false && $i < 9) { - \curl_close($ch); + if (PHP_VERSION_ID < 80000) { curl_close($ch); } // sleep for 100 milliseconds before trying again \usleep(100 * 1000); } else { @@ -281,12 +281,12 @@ protected function sendRequest($method, $url, $headers = [], $body = [], $change curl_error($ch), curl_errno($ch) ); - curl_close($ch); + if (PHP_VERSION_ID < 80000) { curl_close($ch); } $this->fail($message); return null; } - curl_close($ch); + if (PHP_VERSION_ID < 80000) { curl_close($ch); } return $response; } diff --git a/tests/DistributedTracing/GH1070OriginHeaderSegfault/index.php b/tests/DistributedTracing/GH1070OriginHeaderSegfault/index.php index 7adeded953f..5d49c2b8378 100644 --- a/tests/DistributedTracing/GH1070OriginHeaderSegfault/index.php +++ b/tests/DistributedTracing/GH1070OriginHeaderSegfault/index.php @@ -7,4 +7,4 @@ curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $output = curl_exec($ch); -curl_close($ch); +if (PHP_VERSION_ID < 80000) { curl_close($ch); } diff --git a/tests/Frameworks/Custom/Version_Autoloaded/no-root-span b/tests/Frameworks/Custom/Version_Autoloaded/no-root-span index 3c081b49954..e627853f793 100755 --- a/tests/Frameworks/Custom/Version_Autoloaded/no-root-span +++ b/tests/Frameworks/Custom/Version_Autoloaded/no-root-span @@ -11,7 +11,7 @@ function my_app() $ch = curl_init('http://httpbin-integration/status/200'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_exec($ch); - curl_close($ch); + if (PHP_VERSION_ID < 80000) { curl_close($ch); } $mysqli = \mysqli_connect('mysql-integration', 'test', 'test', 'test'); if ($mysqli) { diff --git a/tests/Frameworks/WordPress/Version_4_8/wp-includes/Requests/Transport/cURL.php b/tests/Frameworks/WordPress/Version_4_8/wp-includes/Requests/Transport/cURL.php index 4429edb6473..7adac85816f 100644 --- a/tests/Frameworks/WordPress/Version_4_8/wp-includes/Requests/Transport/cURL.php +++ b/tests/Frameworks/WordPress/Version_4_8/wp-includes/Requests/Transport/cURL.php @@ -112,7 +112,7 @@ public function __construct() { */ public function __destruct() { if (is_resource($this->handle)) { - curl_close($this->handle); + if (PHP_VERSION_ID < 80000) { curl_close($this->handle); } } } @@ -254,7 +254,7 @@ public function request_multiple($requests, $options) { } curl_multi_remove_handle($multihandle, $done['handle']); - curl_close($done['handle']); + if (PHP_VERSION_ID < 80000) { curl_close($done['handle']); } if (!is_string($responses[$key])) { $options['hooks']->dispatch('multiple.request.complete', array(&$responses[$key], $key)); diff --git a/tests/Frameworks/WordPress/Version_4_8/wp-includes/SimplePie/File.php b/tests/Frameworks/WordPress/Version_4_8/wp-includes/SimplePie/File.php index b7d1a2ac9b6..433720273b7 100644 --- a/tests/Frameworks/WordPress/Version_4_8/wp-includes/SimplePie/File.php +++ b/tests/Frameworks/WordPress/Version_4_8/wp-includes/SimplePie/File.php @@ -127,7 +127,7 @@ public function __construct($url, $timeout = 10, $redirects = 5, $headers = null else { $info = curl_getinfo($fp); - curl_close($fp); + if (PHP_VERSION_ID < 80000) { curl_close($fp); } $this->headers = explode("\r\n\r\n", $this->headers, $info['redirect_count'] + 1); $this->headers = array_pop($this->headers); $parser = new SimplePie_HTTP_Parser($this->headers); diff --git a/tests/Frameworks/WordPress/Version_4_8/wp-includes/class-wp-http-curl.php b/tests/Frameworks/WordPress/Version_4_8/wp-includes/class-wp-http-curl.php index 790e93cffb5..2637f273b26 100644 --- a/tests/Frameworks/WordPress/Version_4_8/wp-includes/class-wp-http-curl.php +++ b/tests/Frameworks/WordPress/Version_4_8/wp-includes/class-wp-http-curl.php @@ -224,15 +224,15 @@ public function request($url, $args = array()) { curl_exec( $handle ); if ( $curl_error = curl_error( $handle ) ) { - curl_close( $handle ); + if (PHP_VERSION_ID < 80000) { curl_close( $handle ); } return new WP_Error( 'http_request_failed', $curl_error ); } if ( in_array( curl_getinfo( $handle, CURLINFO_HTTP_CODE ), array( 301, 302 ) ) ) { - curl_close( $handle ); + if (PHP_VERSION_ID < 80000) { curl_close( $handle ); } return new WP_Error( 'http_request_failed', __( 'Too many redirects.' ) ); } - curl_close( $handle ); + if (PHP_VERSION_ID < 80000) { curl_close( $handle ); } return array( 'headers' => array(), 'body' => '', 'response' => array('code' => false, 'message' => false), 'cookies' => array() ); } @@ -252,27 +252,27 @@ public function request($url, $args = array()) { if ( CURLE_WRITE_ERROR /* 23 */ == $curl_error ) { if ( ! $this->max_body_length || $this->max_body_length != $bytes_written_total ) { if ( $r['stream'] ) { - curl_close( $handle ); + if (PHP_VERSION_ID < 80000) { curl_close( $handle ); } fclose( $this->stream_handle ); return new WP_Error( 'http_request_failed', __( 'Failed to write request to temporary file.' ) ); } else { - curl_close( $handle ); + if (PHP_VERSION_ID < 80000) { curl_close( $handle ); } return new WP_Error( 'http_request_failed', curl_error( $handle ) ); } } } else { if ( $curl_error = curl_error( $handle ) ) { - curl_close( $handle ); + if (PHP_VERSION_ID < 80000) { curl_close( $handle ); } return new WP_Error( 'http_request_failed', $curl_error ); } } if ( in_array( curl_getinfo( $handle, CURLINFO_HTTP_CODE ), array( 301, 302 ) ) ) { - curl_close( $handle ); + if (PHP_VERSION_ID < 80000) { curl_close( $handle ); } return new WP_Error( 'http_request_failed', __( 'Too many redirects.' ) ); } } - curl_close( $handle ); + if (PHP_VERSION_ID < 80000) { curl_close( $handle ); } if ( $r['stream'] ) fclose( $this->stream_handle ); diff --git a/tests/Frameworks/WordPress/Version_5_5/wp-includes/Requests/Transport/cURL.php b/tests/Frameworks/WordPress/Version_5_5/wp-includes/Requests/Transport/cURL.php index 4429edb6473..7adac85816f 100644 --- a/tests/Frameworks/WordPress/Version_5_5/wp-includes/Requests/Transport/cURL.php +++ b/tests/Frameworks/WordPress/Version_5_5/wp-includes/Requests/Transport/cURL.php @@ -112,7 +112,7 @@ public function __construct() { */ public function __destruct() { if (is_resource($this->handle)) { - curl_close($this->handle); + if (PHP_VERSION_ID < 80000) { curl_close($this->handle); } } } @@ -254,7 +254,7 @@ public function request_multiple($requests, $options) { } curl_multi_remove_handle($multihandle, $done['handle']); - curl_close($done['handle']); + if (PHP_VERSION_ID < 80000) { curl_close($done['handle']); } if (!is_string($responses[$key])) { $options['hooks']->dispatch('multiple.request.complete', array(&$responses[$key], $key)); diff --git a/tests/Frameworks/WordPress/Version_5_5/wp-includes/SimplePie/File.php b/tests/Frameworks/WordPress/Version_5_5/wp-includes/SimplePie/File.php index 82db47ec9b7..6c751807b42 100644 --- a/tests/Frameworks/WordPress/Version_5_5/wp-includes/SimplePie/File.php +++ b/tests/Frameworks/WordPress/Version_5_5/wp-includes/SimplePie/File.php @@ -135,7 +135,7 @@ public function __construct($url, $timeout = 10, $redirects = 5, $headers = null if ($info = curl_getinfo($fp)) { $this->url = $info['url']; } - curl_close($fp); + if (PHP_VERSION_ID < 80000) { curl_close($fp); } $this->headers = SimplePie_HTTP_Parser::prepareHeaders($this->headers, $info['redirect_count'] + 1); $parser = new SimplePie_HTTP_Parser($this->headers); if ($parser->parse()) diff --git a/tests/Frameworks/WordPress/Version_5_5/wp-includes/class-wp-http-curl.php b/tests/Frameworks/WordPress/Version_5_5/wp-includes/class-wp-http-curl.php index dd4cab92292..2dcb94aa342 100644 --- a/tests/Frameworks/WordPress/Version_5_5/wp-includes/class-wp-http-curl.php +++ b/tests/Frameworks/WordPress/Version_5_5/wp-includes/class-wp-http-curl.php @@ -235,15 +235,15 @@ public function request( $url, $args = array() ) { $curl_error = curl_error( $handle ); if ( $curl_error ) { - curl_close( $handle ); + if (PHP_VERSION_ID < 80000) { curl_close( $handle ); } return new WP_Error( 'http_request_failed', $curl_error ); } if ( in_array( curl_getinfo( $handle, CURLINFO_HTTP_CODE ), array( 301, 302 ), true ) ) { - curl_close( $handle ); + if (PHP_VERSION_ID < 80000) { curl_close( $handle ); } return new WP_Error( 'http_request_failed', __( 'Too many redirects.' ) ); } - curl_close( $handle ); + if (PHP_VERSION_ID < 80000) { curl_close( $handle ); } return array( 'headers' => array(), 'body' => '', @@ -271,28 +271,28 @@ public function request( $url, $args = array() ) { if ( CURLE_WRITE_ERROR /* 23 */ == $curl_error ) { if ( ! $this->max_body_length || $this->max_body_length != $bytes_written_total ) { if ( $parsed_args['stream'] ) { - curl_close( $handle ); + if (PHP_VERSION_ID < 80000) { curl_close( $handle ); } fclose( $this->stream_handle ); return new WP_Error( 'http_request_failed', __( 'Failed to write request to temporary file.' ) ); } else { - curl_close( $handle ); + if (PHP_VERSION_ID < 80000) { curl_close( $handle ); } return new WP_Error( 'http_request_failed', curl_error( $handle ) ); } } } else { $curl_error = curl_error( $handle ); if ( $curl_error ) { - curl_close( $handle ); + if (PHP_VERSION_ID < 80000) { curl_close( $handle ); } return new WP_Error( 'http_request_failed', $curl_error ); } } if ( in_array( curl_getinfo( $handle, CURLINFO_HTTP_CODE ), array( 301, 302 ), true ) ) { - curl_close( $handle ); + if (PHP_VERSION_ID < 80000) { curl_close( $handle ); } return new WP_Error( 'http_request_failed', __( 'Too many redirects.' ) ); } } - curl_close( $handle ); + if (PHP_VERSION_ID < 80000) { curl_close( $handle ); } if ( $parsed_args['stream'] ) { fclose( $this->stream_handle ); diff --git a/tests/Frameworks/WordPress/Version_5_9/wp-includes/Requests/Transport/cURL.php b/tests/Frameworks/WordPress/Version_5_9/wp-includes/Requests/Transport/cURL.php index 01bcf3b719f..f4a45c6fcfb 100644 --- a/tests/Frameworks/WordPress/Version_5_9/wp-includes/Requests/Transport/cURL.php +++ b/tests/Frameworks/WordPress/Version_5_9/wp-includes/Requests/Transport/cURL.php @@ -114,7 +114,7 @@ public function __construct() { */ public function __destruct() { if (is_resource($this->handle)) { - curl_close($this->handle); + if (PHP_VERSION_ID < 80000) { curl_close($this->handle); } } } @@ -257,7 +257,7 @@ public function request_multiple($requests, $options) { } curl_multi_remove_handle($multihandle, $done['handle']); - curl_close($done['handle']); + if (PHP_VERSION_ID < 80000) { curl_close($done['handle']); } if (!is_string($responses[$key])) { $options['hooks']->dispatch('multiple.request.complete', array(&$responses[$key], $key)); diff --git a/tests/Frameworks/WordPress/Version_5_9/wp-includes/SimplePie/File.php b/tests/Frameworks/WordPress/Version_5_9/wp-includes/SimplePie/File.php index c2d368b3b88..ec5033d8bca 100644 --- a/tests/Frameworks/WordPress/Version_5_9/wp-includes/SimplePie/File.php +++ b/tests/Frameworks/WordPress/Version_5_9/wp-includes/SimplePie/File.php @@ -131,7 +131,7 @@ public function __construct($url, $timeout = 10, $redirects = 5, $headers = null if ($info = curl_getinfo($fp)) { $this->url = $info['url']; } - curl_close($fp); + if (PHP_VERSION_ID < 80000) { curl_close($fp); } $this->headers = SimplePie_HTTP_Parser::prepareHeaders($this->headers, $info['redirect_count'] + 1); $parser = new SimplePie_HTTP_Parser($this->headers); if ($parser->parse()) diff --git a/tests/Frameworks/WordPress/Version_5_9/wp-includes/class-wp-http-curl.php b/tests/Frameworks/WordPress/Version_5_9/wp-includes/class-wp-http-curl.php index e36aa71c089..ac6d2bba248 100644 --- a/tests/Frameworks/WordPress/Version_5_9/wp-includes/class-wp-http-curl.php +++ b/tests/Frameworks/WordPress/Version_5_9/wp-includes/class-wp-http-curl.php @@ -235,15 +235,15 @@ public function request( $url, $args = array() ) { $curl_error = curl_error( $handle ); if ( $curl_error ) { - curl_close( $handle ); + if (PHP_VERSION_ID < 80000) { curl_close( $handle ); } return new WP_Error( 'http_request_failed', $curl_error ); } if ( in_array( curl_getinfo( $handle, CURLINFO_HTTP_CODE ), array( 301, 302 ), true ) ) { - curl_close( $handle ); + if (PHP_VERSION_ID < 80000) { curl_close( $handle ); } return new WP_Error( 'http_request_failed', __( 'Too many redirects.' ) ); } - curl_close( $handle ); + if (PHP_VERSION_ID < 80000) { curl_close( $handle ); } return array( 'headers' => array(), 'body' => '', @@ -272,28 +272,28 @@ public function request( $url, $args = array() ) { if ( CURLE_WRITE_ERROR /* 23 */ == $curl_error ) { if ( ! $this->max_body_length || $this->max_body_length != $bytes_written_total ) { if ( $parsed_args['stream'] ) { - curl_close( $handle ); + if (PHP_VERSION_ID < 80000) { curl_close( $handle ); } fclose( $this->stream_handle ); return new WP_Error( 'http_request_failed', __( 'Failed to write request to temporary file.' ) ); } else { - curl_close( $handle ); + if (PHP_VERSION_ID < 80000) { curl_close( $handle ); } return new WP_Error( 'http_request_failed', curl_error( $handle ) ); } } } else { $curl_error = curl_error( $handle ); if ( $curl_error ) { - curl_close( $handle ); + if (PHP_VERSION_ID < 80000) { curl_close( $handle ); } return new WP_Error( 'http_request_failed', $curl_error ); } } if ( in_array( curl_getinfo( $handle, CURLINFO_HTTP_CODE ), array( 301, 302 ), true ) ) { - curl_close( $handle ); + if (PHP_VERSION_ID < 80000) { curl_close( $handle ); } return new WP_Error( 'http_request_failed', __( 'Too many redirects.' ) ); } } - curl_close( $handle ); + if (PHP_VERSION_ID < 80000) { curl_close( $handle ); } if ( $parsed_args['stream'] ) { fclose( $this->stream_handle ); diff --git a/tests/Frameworks/WordPress/Version_6_1/wp-includes/Requests/Transport/cURL.php b/tests/Frameworks/WordPress/Version_6_1/wp-includes/Requests/Transport/cURL.php index 01bcf3b719f..f4a45c6fcfb 100644 --- a/tests/Frameworks/WordPress/Version_6_1/wp-includes/Requests/Transport/cURL.php +++ b/tests/Frameworks/WordPress/Version_6_1/wp-includes/Requests/Transport/cURL.php @@ -114,7 +114,7 @@ public function __construct() { */ public function __destruct() { if (is_resource($this->handle)) { - curl_close($this->handle); + if (PHP_VERSION_ID < 80000) { curl_close($this->handle); } } } @@ -257,7 +257,7 @@ public function request_multiple($requests, $options) { } curl_multi_remove_handle($multihandle, $done['handle']); - curl_close($done['handle']); + if (PHP_VERSION_ID < 80000) { curl_close($done['handle']); } if (!is_string($responses[$key])) { $options['hooks']->dispatch('multiple.request.complete', array(&$responses[$key], $key)); diff --git a/tests/Frameworks/WordPress/Version_6_1/wp-includes/SimplePie/File.php b/tests/Frameworks/WordPress/Version_6_1/wp-includes/SimplePie/File.php index c2d368b3b88..ec5033d8bca 100644 --- a/tests/Frameworks/WordPress/Version_6_1/wp-includes/SimplePie/File.php +++ b/tests/Frameworks/WordPress/Version_6_1/wp-includes/SimplePie/File.php @@ -131,7 +131,7 @@ public function __construct($url, $timeout = 10, $redirects = 5, $headers = null if ($info = curl_getinfo($fp)) { $this->url = $info['url']; } - curl_close($fp); + if (PHP_VERSION_ID < 80000) { curl_close($fp); } $this->headers = SimplePie_HTTP_Parser::prepareHeaders($this->headers, $info['redirect_count'] + 1); $parser = new SimplePie_HTTP_Parser($this->headers); if ($parser->parse()) diff --git a/tests/Frameworks/WordPress/Version_6_1/wp-includes/class-wp-http-curl.php b/tests/Frameworks/WordPress/Version_6_1/wp-includes/class-wp-http-curl.php index 9b201af110b..2417deae0d5 100644 --- a/tests/Frameworks/WordPress/Version_6_1/wp-includes/class-wp-http-curl.php +++ b/tests/Frameworks/WordPress/Version_6_1/wp-includes/class-wp-http-curl.php @@ -236,15 +236,15 @@ public function request( $url, $args = array() ) { $curl_error = curl_error( $handle ); if ( $curl_error ) { - curl_close( $handle ); + if (PHP_VERSION_ID < 80000) { curl_close( $handle ); } return new WP_Error( 'http_request_failed', $curl_error ); } if ( in_array( curl_getinfo( $handle, CURLINFO_HTTP_CODE ), array( 301, 302 ), true ) ) { - curl_close( $handle ); + if (PHP_VERSION_ID < 80000) { curl_close( $handle ); } return new WP_Error( 'http_request_failed', __( 'Too many redirects.' ) ); } - curl_close( $handle ); + if (PHP_VERSION_ID < 80000) { curl_close( $handle ); } return array( 'headers' => array(), 'body' => '', @@ -273,28 +273,28 @@ public function request( $url, $args = array() ) { if ( CURLE_WRITE_ERROR /* 23 */ === $curl_error ) { if ( ! $this->max_body_length || $this->max_body_length !== $bytes_written_total ) { if ( $parsed_args['stream'] ) { - curl_close( $handle ); + if (PHP_VERSION_ID < 80000) { curl_close( $handle ); } fclose( $this->stream_handle ); return new WP_Error( 'http_request_failed', __( 'Failed to write request to temporary file.' ) ); } else { - curl_close( $handle ); + if (PHP_VERSION_ID < 80000) { curl_close( $handle ); } return new WP_Error( 'http_request_failed', curl_error( $handle ) ); } } } else { $curl_error = curl_error( $handle ); if ( $curl_error ) { - curl_close( $handle ); + if (PHP_VERSION_ID < 80000) { curl_close( $handle ); } return new WP_Error( 'http_request_failed', $curl_error ); } } if ( in_array( curl_getinfo( $handle, CURLINFO_HTTP_CODE ), array( 301, 302 ), true ) ) { - curl_close( $handle ); + if (PHP_VERSION_ID < 80000) { curl_close( $handle ); } return new WP_Error( 'http_request_failed', __( 'Too many redirects.' ) ); } } - curl_close( $handle ); + if (PHP_VERSION_ID < 80000) { curl_close( $handle ); } if ( $parsed_args['stream'] ) { fclose( $this->stream_handle ); diff --git a/tests/Frameworks/ZendFramework/Version_1_12/library/Zend/Http/Client/Adapter/Curl.php b/tests/Frameworks/ZendFramework/Version_1_12/library/Zend/Http/Client/Adapter/Curl.php index cd26f8bb86b..125b7b65d13 100644 --- a/tests/Frameworks/ZendFramework/Version_1_12/library/Zend/Http/Client/Adapter/Curl.php +++ b/tests/Frameworks/ZendFramework/Version_1_12/library/Zend/Http/Client/Adapter/Curl.php @@ -496,7 +496,7 @@ public function read() public function close() { if(is_resource($this->_curl)) { - curl_close($this->_curl); + if (PHP_VERSION_ID < 80000) { curl_close($this->_curl); } } $this->_curl = null; $this->_connected_to = array(null, null); diff --git a/tests/Frameworks/ZendFramework/Version_1_21/library/Zend/Http/Client/Adapter/Curl.php b/tests/Frameworks/ZendFramework/Version_1_21/library/Zend/Http/Client/Adapter/Curl.php index f6945c8907b..334bd1f0981 100644 --- a/tests/Frameworks/ZendFramework/Version_1_21/library/Zend/Http/Client/Adapter/Curl.php +++ b/tests/Frameworks/ZendFramework/Version_1_21/library/Zend/Http/Client/Adapter/Curl.php @@ -497,7 +497,7 @@ public function read() public function close() { if(is_resource($this->_curl)) { - curl_close($this->_curl); + if (PHP_VERSION_ID < 80000) { curl_close($this->_curl); } } $this->_curl = null; $this->_connected_to = [null, null]; diff --git a/tests/Integrations/Curl/CurlIntegrationTest.php b/tests/Integrations/Curl/CurlIntegrationTest.php index eed5fb4bbda..91fbc3dbdb4 100644 --- a/tests/Integrations/Curl/CurlIntegrationTest.php +++ b/tests/Integrations/Curl/CurlIntegrationTest.php @@ -21,7 +21,7 @@ public function request() curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HEADERFUNCTION, __CLASS__ . '::parseResponseHeaders'); $response = curl_exec($ch); - curl_close($ch); + if (PHP_VERSION_ID < 80000) { curl_close($ch); } return $response; } } @@ -80,7 +80,7 @@ public function testLoad200UrlOnInit() curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); $this->assertSame('', $response); - curl_close($ch); + if (PHP_VERSION_ID < 80000) { curl_close($ch); } }); $this->assertSpans($traces, [ @@ -105,7 +105,7 @@ public function testLoad200UrlAsOpt() curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); $this->assertSame('', $response); - curl_close($ch); + if (PHP_VERSION_ID < 80000) { curl_close($ch); } }); $this->assertSpans($traces, [ @@ -130,7 +130,7 @@ public function testInlineCredentials() curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); $this->assertStringContains('my_user', $response); - curl_close($ch); + if (PHP_VERSION_ID < 80000) { curl_close($ch); } }); $this->assertSpans($traces, [ @@ -156,7 +156,7 @@ public function testCredentialsViaBasicAuth() curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); $this->assertStringContains('my_user', $response); - curl_close($ch); + if (PHP_VERSION_ID < 80000) { curl_close($ch); } }); $this->assertSpans($traces, [ @@ -235,7 +235,7 @@ public function testLoad404UrlOnInit() curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); $this->assertSame('', $response); - curl_close($ch); + if (PHP_VERSION_ID < 80000) { curl_close($ch); } }); $this->assertSpans($traces, [ @@ -259,7 +259,7 @@ public function testLoadUnroutableIP() curl_setopt($ch, CURLOPT_URL, "http://10.255.255.1/"); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT_MS, 100); curl_exec($ch); - curl_close($ch); + if (PHP_VERSION_ID < 80000) { curl_close($ch); } }); $this->assertSpans($traces, [ @@ -286,7 +286,7 @@ public function testLoadOperationTimeout() curl_setopt($ch, CURLOPT_URL, "http://10.255.255.1/"); curl_setopt($ch, CURLOPT_TIMEOUT_MS, 100); curl_exec($ch); - curl_close($ch); + if (PHP_VERSION_ID < 80000) { curl_close($ch); } }); $this->assertSpans($traces, [ @@ -313,7 +313,7 @@ public function testNonExistingHost() curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); $this->assertFalse($response); - curl_close($ch); + if (PHP_VERSION_ID < 80000) { curl_close($ch); } }); $this->assertSpans($traces, [ @@ -457,7 +457,7 @@ public function testAppendHostnameToServiceName() curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); $this->assertSame('', $response); - curl_close($ch); + if (PHP_VERSION_ID < 80000) { curl_close($ch); } }); $this->assertSpans($traces, [ @@ -488,7 +488,7 @@ public function testAppendHostnameToServiceNameInlineCredentials() curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); $this->assertSame('', $response); - curl_close($ch); + if (PHP_VERSION_ID < 80000) { curl_close($ch); } }); $this->assertSpans($traces, [ @@ -709,7 +709,7 @@ public function testPeerServiceEnabled() curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); $this->assertSame('', $response); - curl_close($ch); + if (PHP_VERSION_ID < 80000) { curl_close($ch); } }); $this->assertSpans($traces, [ @@ -741,7 +741,7 @@ public function testNoFakeServices() curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); $this->assertSame('', $response); - curl_close($ch); + if (PHP_VERSION_ID < 80000) { curl_close($ch); } }); $this->assertSpans($traces, [ diff --git a/tests/Integrations/Curl/curl_in_web_request.php b/tests/Integrations/Curl/curl_in_web_request.php index 366fab7227d..36c7c5ba71a 100644 --- a/tests/Integrations/Curl/curl_in_web_request.php +++ b/tests/Integrations/Curl/curl_in_web_request.php @@ -6,6 +6,6 @@ $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_exec($ch); -curl_close($ch); +if (PHP_VERSION_ID < 80000) { curl_close($ch); } echo "Done\n"; diff --git a/tests/Integrations/Curl/curl_request_headers_with_copied_handle.php b/tests/Integrations/Curl/curl_request_headers_with_copied_handle.php index 6ea7ccf5c4b..9c74405d4d2 100644 --- a/tests/Integrations/Curl/curl_request_headers_with_copied_handle.php +++ b/tests/Integrations/Curl/curl_request_headers_with_copied_handle.php @@ -9,5 +9,5 @@ 'honored: preserved_value', ]); $ch2 = \curl_copy_handle($ch1); -\curl_close($ch1); +if (PHP_VERSION_ID < 80000) { curl_close($ch1); } echo curl_exec($ch2); diff --git a/tests/Integrations/PCNTL/scripts/_functions.php b/tests/Integrations/PCNTL/scripts/_functions.php index e05e51aded5..c52db46ad43 100644 --- a/tests/Integrations/PCNTL/scripts/_functions.php +++ b/tests/Integrations/PCNTL/scripts/_functions.php @@ -8,5 +8,5 @@ function call_httpbin($path) curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $output = curl_exec($ch); - curl_close($ch); + if (PHP_VERSION_ID < 80000) { curl_close($ch); } } diff --git a/tests/PackageUpdater.php b/tests/PackageUpdater.php index aa3ed0c6d7e..09a440f2c2a 100644 --- a/tests/PackageUpdater.php +++ b/tests/PackageUpdater.php @@ -135,7 +135,7 @@ private function getLatestVersion(string $library): ?string ]); $response = curl_exec($ch); - curl_close($ch); + if (PHP_VERSION_ID < 80000) { curl_close($ch); } if (!$response) { return null; } @@ -185,4 +185,4 @@ private function displaySummary(): void } } -(new PackageUpdater())->run(); \ No newline at end of file +(new PackageUpdater())->run(); diff --git a/tests/PostInstallHook/classes.php b/tests/PostInstallHook/classes.php index e1e456ffb14..df293485a9f 100644 --- a/tests/PostInstallHook/classes.php +++ b/tests/PostInstallHook/classes.php @@ -111,7 +111,7 @@ public function __construct(CliInput $input, Request $request) if (!$response) { $errorCode = curl_errno($ch); $error = curl_error($ch); - curl_close($ch); + if (PHP_VERSION_ID < 80000) { curl_close($ch); } rewind($verbose); printf( @@ -126,7 +126,7 @@ public function __construct(CliInput $input, Request $request) ); exit(1); } - curl_close($ch); + if (PHP_VERSION_ID < 80000) { curl_close($ch); } $this->status = json_decode($response, true); if ( !$this->status diff --git a/tests/ext/background-sender/default_unix_domain_socket_agent.phpt b/tests/ext/background-sender/default_unix_domain_socket_agent.phpt index 2a73a7fb5db..8b08b338e03 100644 --- a/tests/ext/background-sender/default_unix_domain_socket_agent.phpt +++ b/tests/ext/background-sender/default_unix_domain_socket_agent.phpt @@ -4,7 +4,7 @@ If an agent unix domain socket exists it will try to connect to it - + --ENV-- DD_AGENT_HOST= --FILE-- diff --git a/tests/ext/from_php_7_3_bug61728.phpt b/tests/ext/from_php_7_3_bug61728.phpt index 1e28a70a661..42af25e4016 100644 --- a/tests/ext/from_php_7_3_bug61728.phpt +++ b/tests/ext/from_php_7_3_bug61728.phpt @@ -23,7 +23,7 @@ function read ($id) { function write ($id, $sess_data) { ob_start("output_html"); echo "laruence"; - ob_end_flush(); + @ob_end_flush(); return true; } diff --git a/tests/ext/integrations/curl/distributed_tracing_curl.phpt b/tests/ext/integrations/curl/distributed_tracing_curl.phpt index aef5c3aa21b..9b5a8073199 100644 --- a/tests/ext/integrations/curl/distributed_tracing_curl.phpt +++ b/tests/ext/integrations/curl/distributed_tracing_curl.phpt @@ -27,7 +27,7 @@ curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); show_curl_error_on_fail($ch); -curl_close($ch); +if (PHP_VERSION_ID < 80000) { curl_close($ch); } include 'distributed_tracing.inc'; $headers = dt_decode_headers_from_httpbin($response); diff --git a/tests/ext/integrations/curl/distributed_tracing_curl_copy_handle.phpt b/tests/ext/integrations/curl/distributed_tracing_curl_copy_handle.phpt index 09de7f66e47..8f9b7cf10fd 100644 --- a/tests/ext/integrations/curl/distributed_tracing_curl_copy_handle.phpt +++ b/tests/ext/integrations/curl/distributed_tracing_curl_copy_handle.phpt @@ -45,8 +45,8 @@ curl_setopt($ch2, CURLOPT_HTTPHEADER, [ $responses[] = curl_exec($ch2); show_curl_error_on_fail($ch2); -curl_close($ch); -curl_close($ch2); +if (PHP_VERSION_ID < 80000) { curl_close($ch); } +if (PHP_VERSION_ID < 80000) { curl_close($ch2); } include 'distributed_tracing.inc'; foreach ($responses as $key => $response) { diff --git a/tests/ext/integrations/curl/distributed_tracing_curl_disabled_baggage.phpt b/tests/ext/integrations/curl/distributed_tracing_curl_disabled_baggage.phpt index 9822041b1c8..2262e64e733 100644 --- a/tests/ext/integrations/curl/distributed_tracing_curl_disabled_baggage.phpt +++ b/tests/ext/integrations/curl/distributed_tracing_curl_disabled_baggage.phpt @@ -27,7 +27,7 @@ curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); show_curl_error_on_fail($ch); -curl_close($ch); +if (PHP_VERSION_ID < 80000) { curl_close($ch); } // Extract headers from the response include 'distributed_tracing.inc'; diff --git a/tests/ext/integrations/curl/distributed_tracing_curl_drop_dm.phpt b/tests/ext/integrations/curl/distributed_tracing_curl_drop_dm.phpt index dd31aac00e5..f287e0bbaea 100644 --- a/tests/ext/integrations/curl/distributed_tracing_curl_drop_dm.phpt +++ b/tests/ext/integrations/curl/distributed_tracing_curl_drop_dm.phpt @@ -20,7 +20,7 @@ curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); show_curl_error_on_fail($ch); -curl_close($ch); +if (PHP_VERSION_ID < 80000) { curl_close($ch); } include 'distributed_tracing.inc'; $headers = dt_decode_headers_from_httpbin($response); diff --git a/tests/ext/integrations/curl/distributed_tracing_curl_existing_headers_001.phpt b/tests/ext/integrations/curl/distributed_tracing_curl_existing_headers_001.phpt index bba8baf561c..db843a66627 100644 --- a/tests/ext/integrations/curl/distributed_tracing_curl_existing_headers_001.phpt +++ b/tests/ext/integrations/curl/distributed_tracing_curl_existing_headers_001.phpt @@ -33,7 +33,7 @@ $responses[] = curl_exec($ch); show_curl_error_on_fail($ch); $responses[] = curl_exec($ch); show_curl_error_on_fail($ch); -curl_close($ch); +if (PHP_VERSION_ID < 80000) { curl_close($ch); } include 'distributed_tracing.inc'; foreach ($responses as $key => $response) { diff --git a/tests/ext/integrations/curl/distributed_tracing_curl_existing_headers_002.phpt b/tests/ext/integrations/curl/distributed_tracing_curl_existing_headers_002.phpt index f63d45dfbd4..f5f15c9bfd8 100644 --- a/tests/ext/integrations/curl/distributed_tracing_curl_existing_headers_002.phpt +++ b/tests/ext/integrations/curl/distributed_tracing_curl_existing_headers_002.phpt @@ -33,7 +33,7 @@ $responses[] = curl_exec($ch); show_curl_error_on_fail($ch); $responses[] = curl_exec($ch); show_curl_error_on_fail($ch); -curl_close($ch); +if (PHP_VERSION_ID < 80000) { curl_close($ch); } include 'distributed_tracing.inc'; foreach ($responses as $key => $response) { diff --git a/tests/ext/integrations/curl/distributed_tracing_curl_existing_headers_003.phpt b/tests/ext/integrations/curl/distributed_tracing_curl_existing_headers_003.phpt index 971955fd9b3..f6ca3ad72d7 100644 --- a/tests/ext/integrations/curl/distributed_tracing_curl_existing_headers_003.phpt +++ b/tests/ext/integrations/curl/distributed_tracing_curl_existing_headers_003.phpt @@ -51,7 +51,7 @@ $responses[] = curl_exec($ch); show_curl_error_on_fail($ch); $responses[] = curl_exec($ch); show_curl_error_on_fail($ch); -curl_close($ch); +if (PHP_VERSION_ID < 80000) { curl_close($ch); } include 'distributed_tracing.inc'; foreach ($responses as $key => $response) { diff --git a/tests/ext/integrations/curl/distributed_tracing_curl_existing_headers_004.phpt b/tests/ext/integrations/curl/distributed_tracing_curl_existing_headers_004.phpt index 4955b931847..5171d800c85 100644 --- a/tests/ext/integrations/curl/distributed_tracing_curl_existing_headers_004.phpt +++ b/tests/ext/integrations/curl/distributed_tracing_curl_existing_headers_004.phpt @@ -32,7 +32,7 @@ curl_setopt_array($ch, [ DDTrace\Testing\emit_asm_event(); $response = curl_exec($ch); show_curl_error_on_fail($ch); -curl_close($ch); +if (PHP_VERSION_ID < 80000) { curl_close($ch); } include 'distributed_tracing.inc'; $headers = dt_decode_headers_from_httpbin($response); @@ -42,4 +42,4 @@ var_dump($tags['_dd.p.ts']); ?> --EXPECTF-- -string(2) "02" \ No newline at end of file +string(2) "02" diff --git a/tests/ext/integrations/curl/distributed_tracing_curl_existing_headers_005.phpt b/tests/ext/integrations/curl/distributed_tracing_curl_existing_headers_005.phpt index 4492608601b..1b9a9781567 100644 --- a/tests/ext/integrations/curl/distributed_tracing_curl_existing_headers_005.phpt +++ b/tests/ext/integrations/curl/distributed_tracing_curl_existing_headers_005.phpt @@ -31,7 +31,7 @@ curl_setopt_array($ch, [ $response = curl_exec($ch); show_curl_error_on_fail($ch); -curl_close($ch); +if (PHP_VERSION_ID < 80000) { curl_close($ch); } include 'distributed_tracing.inc'; $headers = dt_decode_headers_from_httpbin($response); @@ -41,4 +41,4 @@ var_dump(isset($tags['_dd.p.ts'])); ?> --EXPECTF-- -bool(false) \ No newline at end of file +bool(false) diff --git a/tests/ext/integrations/curl/distributed_tracing_curl_existing_headers_006.phpt b/tests/ext/integrations/curl/distributed_tracing_curl_existing_headers_006.phpt index 6a52216c653..843f2c6eb93 100644 --- a/tests/ext/integrations/curl/distributed_tracing_curl_existing_headers_006.phpt +++ b/tests/ext/integrations/curl/distributed_tracing_curl_existing_headers_006.phpt @@ -32,7 +32,7 @@ curl_setopt_array($ch, [ $response = curl_exec($ch); show_curl_error_on_fail($ch); -curl_close($ch); +if (PHP_VERSION_ID < 80000) { curl_close($ch); } include 'distributed_tracing.inc'; $headers = dt_decode_headers_from_httpbin($response); @@ -40,4 +40,4 @@ var_dump(isset($headers['x-datadog-tags'])); ?> --EXPECTF-- -bool(false) \ No newline at end of file +bool(false) diff --git a/tests/ext/integrations/curl/distributed_tracing_curl_existing_headers_007.phpt b/tests/ext/integrations/curl/distributed_tracing_curl_existing_headers_007.phpt index d22282148c5..db12d6f8f14 100644 --- a/tests/ext/integrations/curl/distributed_tracing_curl_existing_headers_007.phpt +++ b/tests/ext/integrations/curl/distributed_tracing_curl_existing_headers_007.phpt @@ -32,7 +32,7 @@ curl_setopt_array($ch, [ DDTrace\Testing\emit_asm_event(); $response = curl_exec($ch); show_curl_error_on_fail($ch); -curl_close($ch); +if (PHP_VERSION_ID < 80000) { curl_close($ch); } include 'distributed_tracing.inc'; $headers = dt_decode_headers_from_httpbin($response); @@ -42,4 +42,4 @@ var_dump($tags['_dd.p.ts']); ?> --EXPECTF-- -string(2) "02" \ No newline at end of file +string(2) "02" diff --git a/tests/ext/integrations/curl/distributed_tracing_curl_invalid_tags.phpt b/tests/ext/integrations/curl/distributed_tracing_curl_invalid_tags.phpt index 788edaafda6..806838576fe 100644 --- a/tests/ext/integrations/curl/distributed_tracing_curl_invalid_tags.phpt +++ b/tests/ext/integrations/curl/distributed_tracing_curl_invalid_tags.phpt @@ -22,7 +22,7 @@ curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); show_curl_error_on_fail($ch); -curl_close($ch); +if (PHP_VERSION_ID < 80000) { curl_close($ch); } include 'distributed_tracing.inc'; $headers = dt_decode_headers_from_httpbin($response); diff --git a/tests/ext/integrations/curl/distributed_tracing_curl_propagate_asm_event.phpt b/tests/ext/integrations/curl/distributed_tracing_curl_propagate_asm_event.phpt index cb86dcd71bf..58205173f9e 100644 --- a/tests/ext/integrations/curl/distributed_tracing_curl_propagate_asm_event.phpt +++ b/tests/ext/integrations/curl/distributed_tracing_curl_propagate_asm_event.phpt @@ -19,7 +19,7 @@ function query_headers() { curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); - curl_close($ch); + if (PHP_VERSION_ID < 80000) { curl_close($ch); } return dt_decode_headers_from_httpbin($response); } diff --git a/tests/ext/integrations/curl/distributed_tracing_curl_propagate_custom_tags.phpt b/tests/ext/integrations/curl/distributed_tracing_curl_propagate_custom_tags.phpt index fda031a87d8..5087e016642 100644 --- a/tests/ext/integrations/curl/distributed_tracing_curl_propagate_custom_tags.phpt +++ b/tests/ext/integrations/curl/distributed_tracing_curl_propagate_custom_tags.phpt @@ -17,7 +17,7 @@ function query_headers() { curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); - curl_close($ch); + if (PHP_VERSION_ID < 80000) { curl_close($ch); } return dt_decode_headers_from_httpbin($response); } diff --git a/tests/ext/integrations/curl/distributed_tracing_curl_propagate_tags.phpt b/tests/ext/integrations/curl/distributed_tracing_curl_propagate_tags.phpt index 498b4c8124b..473faf0f938 100644 --- a/tests/ext/integrations/curl/distributed_tracing_curl_propagate_tags.phpt +++ b/tests/ext/integrations/curl/distributed_tracing_curl_propagate_tags.phpt @@ -19,7 +19,7 @@ function query_headers() { curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); - curl_close($ch); + if (PHP_VERSION_ID < 80000) { curl_close($ch); } return dt_decode_headers_from_httpbin($response); } diff --git a/tests/ext/integrations/curl/distributed_tracing_curl_sampling_priority.phpt b/tests/ext/integrations/curl/distributed_tracing_curl_sampling_priority.phpt index b0a86d0072d..ea5108c49b5 100644 --- a/tests/ext/integrations/curl/distributed_tracing_curl_sampling_priority.phpt +++ b/tests/ext/integrations/curl/distributed_tracing_curl_sampling_priority.phpt @@ -17,7 +17,7 @@ function query_headers() { curl_setopt($ch, CURLOPT_READFUNCTION, function () {}); // must not leak $response = curl_exec($ch); show_curl_error_on_fail($ch); - curl_close($ch); + if (PHP_VERSION_ID < 80000) { curl_close($ch); } return dt_decode_headers_from_httpbin($response); } diff --git a/tests/ext/integrations/curl/distributed_tracing_curl_tracestate.phpt b/tests/ext/integrations/curl/distributed_tracing_curl_tracestate.phpt index 3f9e84ded26..6eef07a93dc 100644 --- a/tests/ext/integrations/curl/distributed_tracing_curl_tracestate.phpt +++ b/tests/ext/integrations/curl/distributed_tracing_curl_tracestate.phpt @@ -20,7 +20,7 @@ curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); show_curl_error_on_fail($ch); -curl_close($ch); +if (PHP_VERSION_ID < 80000) { curl_close($ch); } include 'distributed_tracing.inc'; $headers = dt_decode_headers_from_httpbin($response); diff --git a/tests/ext/sandbox/hook_function/hook_does_not_leak_error.phpt b/tests/ext/sandbox/hook_function/hook_does_not_leak_error.phpt index 761aa2c1934..3cb5d3596f9 100644 --- a/tests/ext/sandbox/hook_function/hook_does_not_leak_error.phpt +++ b/tests/ext/sandbox/hook_function/hook_does_not_leak_error.phpt @@ -15,7 +15,8 @@ set_error_handler(function() { return false; }); -function foo() {} +function foo() { echo "foo\n"; } + DDTrace\trace_function("foo", function() { trigger_error("Fatal", E_USER_ERROR); }); @@ -27,6 +28,9 @@ foo(); ?> --EXPECTF-- +foo +[ddtrace] [warning] Error raised in ddtrace's closure defined at %s:%d for foo(): Fatal in %s on line %d int(200) +foo [ddtrace] [warning] Error raised in ddtrace's closure defined at %s:%d for foo(): Fatal in %s on line %d [ddtrace] [info] Flushing trace of size %s diff --git a/tests/randomized/app/src/RandomizedTests/Snippets.php b/tests/randomized/app/src/RandomizedTests/Snippets.php index 2b8ca3f219f..3515c1fa5d2 100644 --- a/tests/randomized/app/src/RandomizedTests/Snippets.php +++ b/tests/randomized/app/src/RandomizedTests/Snippets.php @@ -187,7 +187,7 @@ public function curlVariant1() curl_setopt($ch, CURLOPT_URL, $this->getCurlUrl()); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $output = curl_exec($ch); - curl_close($ch); + if (PHP_VERSION_ID < 80000) { curl_close($ch); } } public function curlVariant2() diff --git a/tooling/bin/generate-final-artifact.sh b/tooling/bin/generate-final-artifact.sh index fd0f6c30613..10d7af3af53 100755 --- a/tooling/bin/generate-final-artifact.sh +++ b/tooling/bin/generate-final-artifact.sh @@ -13,7 +13,7 @@ tmp_folder_final=$tmp_folder/final architectures=(x86_64 aarch64) -php_apis=(20190902 20200930 20210902 20220829 20230831 20240924) +php_apis=(20190902 20200930 20210902 20220829 20230831 20240924 20250925) if [[ -z ${DDTRACE_MAKE_PACKAGES_ASAN:-} ]]; then php_apis+=(20151012 20160303 20170718 20180731) fi @@ -183,7 +183,7 @@ for architecture in "${architectures[@]}"; do ######################## if [[ -z ${DDTRACE_MAKE_PACKAGES_ASAN:-} ]]; then # Extension - php_apis=(20160303 20170718 20180731 20190902 20200930 20210902 20220829 20230831 20240924) + php_apis=(20160303 20170718 20180731 20190902 20200930 20210902 20220829 20230831 20240924 20250925) for version in "${php_apis[@]}" do for full_target in "${targets[@]}"; do @@ -242,7 +242,7 @@ for architecture in "${architectures[@]}"; do tmp_folder_final_musl_appsec=$tmp_folder_final_musl/dd-library-php/appsec # Extensions - php_apis=(20151012 20160303 20170718 20180731 20190902 20200930 20210902 20220829 20230831 20240924); + php_apis=(20151012 20160303 20170718 20180731 20190902 20200930 20210902 20220829 20230831 20240924 20250925); for php_api in "${php_apis[@]}"; do for full_target in "${targets[@]}"; do target=${full_target#*-} diff --git a/tooling/bin/generate-ssi-package.sh b/tooling/bin/generate-ssi-package.sh index 3b223c34a75..3bcc9a3dfc3 100755 --- a/tooling/bin/generate-ssi-package.sh +++ b/tooling/bin/generate-ssi-package.sh @@ -68,7 +68,7 @@ for architecture in "${architectures[@]}"; do # Products ######################## - php_apis=(20151012 20160303 20170718 20180731 20190902 20200930 20210902 20220829 20230831 20240924) + php_apis=(20151012 20160303 20170718 20180731 20190902 20200930 20210902 20220829 20230831 20240924 20250925) for php_api in "${php_apis[@]}"; do ######################## # Trace diff --git a/tooling/metrics/synthetic.php b/tooling/metrics/synthetic.php index ab7ab8d1310..95d9f9959f7 100644 --- a/tooling/metrics/synthetic.php +++ b/tooling/metrics/synthetic.php @@ -9,7 +9,7 @@ curl_setopt($ch, CURLOPT_URL, 'httpbin-integration/get?client=curl'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $output = curl_exec($ch); - curl_close($ch); + if (PHP_VERSION_ID < 80000) { curl_close($ch); } } for ($queryIndex = 0; $queryIndex < QUERY_COUNT; $queryIndex++) { diff --git a/zend_abstract_interface/exceptions/tests/exceptions.cc b/zend_abstract_interface/exceptions/tests/exceptions.cc index e9c2eeeadd4..e63996c2ee3 100644 --- a/zend_abstract_interface/exceptions/tests/exceptions.cc +++ b/zend_abstract_interface/exceptions/tests/exceptions.cc @@ -14,6 +14,7 @@ TEA_TEST_CASE_WITH_STUB("exceptions", "reading message with non-string type retu zend_string *str = zai_exception_message(Z_OBJ(ex)); REQUIRE(ZSTR_LEN(str) > 0); + zend_string_release(str); zval_ptr_dtor(&ex); }) @@ -25,6 +26,7 @@ TEA_TEST_CASE_WITH_STUB("exceptions", "reading message from exception", "./stubs zend_string *str = zai_exception_message(Z_OBJ(ex)); REQUIRE(zend_string_equals_literal(str, "msg")); + zend_string_release(str); zval_ptr_dtor(&ex); }) @@ -36,6 +38,7 @@ TEA_TEST_CASE_WITH_STUB("exceptions", "reading message from exception subclass", zend_string *str = zai_exception_message(Z_OBJ(ex)); REQUIRE(zend_string_equals_literal(str, "msg")); + zend_string_release(str); zval_ptr_dtor(&ex); }) @@ -47,6 +50,7 @@ TEA_TEST_CASE_WITH_STUB("exceptions", "reading message from error", "./stubs/fun zend_string *str = zai_exception_message(Z_OBJ(ex)); REQUIRE(zend_string_equals_literal(str, "msg")); + zend_string_release(str); zval_ptr_dtor(&ex); }) @@ -58,6 +62,7 @@ TEA_TEST_CASE_WITH_STUB("exceptions", "reading message from error subclass", "./ zend_string *str = zai_exception_message(Z_OBJ(ex)); REQUIRE(zend_string_equals_literal(str, "msg")); + zend_string_release(str); zval_ptr_dtor(&ex); }) diff --git a/zend_abstract_interface/exceptions/tests/stubs/functions.php b/zend_abstract_interface/exceptions/tests/stubs/functions.php index 4a03f7e515b..70c70695c64 100644 --- a/zend_abstract_interface/exceptions/tests/stubs/functions.php +++ b/zend_abstract_interface/exceptions/tests/stubs/functions.php @@ -34,7 +34,9 @@ function broken_exception() { $p->setValue($e, "Not an array"); } $p = $ref->getProperty("message"); - $p->setAccessible(true); + if (PHP_VERSION_ID < 80500) { + $p->setAccessible(true); + } $p->setValue($e, new \stdClass); return $e; } diff --git a/zend_abstract_interface/interceptor/php8/interceptor.c b/zend_abstract_interface/interceptor/php8/interceptor.c index 78e076355cb..60bdda4783f 100644 --- a/zend_abstract_interface/interceptor/php8/interceptor.c +++ b/zend_abstract_interface/interceptor/php8/interceptor.c @@ -751,12 +751,16 @@ static zend_never_inline const void *zai_interceptor_handle_created_generator_fu return zai_interceptor_generator_post_op[2].handler; } +#ifndef ZEND_OPCODE_HANDLER_CCONV +#define ZEND_OPCODE_HANDLER_CCONV ZEND_FASTCALL +#endif + #ifdef __GNUC__ bool zai_interceptor_avoid_compile_opt = true; uintptr_t zai_interceptor_dummy_label_use; // a bit of stuff to make the function control flow undecidable for the compiler, so that it doesn't optimize anything away -static void *ZEND_FASTCALL zai_interceptor_handle_created_generator_goto(void) { +static void *ZEND_OPCODE_HANDLER_CCONV zai_interceptor_handle_created_generator_goto(void) { if (zai_interceptor_avoid_compile_opt) { uintptr_t tmp = (uintptr_t)&&zai_interceptor_handle_created_generator_goto_LABEL2; zai_interceptor_dummy_label_use = tmp; @@ -773,10 +777,17 @@ static void *ZEND_FASTCALL zai_interceptor_handle_created_generator_goto(void) { #endif // Windows & Mac use call VM without IP/FP -static int ZEND_FASTCALL zai_interceptor_handle_created_generator_call(void) { +#if PHP_VERSION_ID < 80500 +static int ZEND_OPCODE_HANDLER_CCONV zai_interceptor_handle_created_generator_call(void) { zai_interceptor_handle_created_generator_func(); return 0 /* ZEND_VM_CONTINUE */; } +#else +static const zend_op *ZEND_OPCODE_HANDLER_CCONV zai_interceptor_handle_created_generator_call(void) { + zai_interceptor_handle_created_generator_func(); + return &zai_interceptor_generator_post_op[2] /* ZEND_VM_CONTINUE */; +} +#endif static zend_object *(*generator_create_prev)(zend_class_entry *class_type); static zend_object *zai_interceptor_generator_create(zend_class_entry *class_type) {