From 24274c052a90102ba27d89bdb60627a505eab095 Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Tue, 30 Jan 2024 14:49:00 +0100 Subject: [PATCH] Fix PHP 8.4 / macos build Signed-off-by: Bob Weinand --- config.m4 | 2 +- ext/logging.c | 2 +- ext/random.c | 4 ++++ libdatadog | 2 +- .../uri_normalization/uri_normalization.c | 14 +++++++++----- 5 files changed, 16 insertions(+), 8 deletions(-) diff --git a/config.m4 b/config.m4 index 3c6319a6cc..a366b24fc7 100644 --- a/config.m4 +++ b/config.m4 @@ -289,7 +289,7 @@ if test "$PHP_DDTRACE" != "no"; then cat <> Makefile.fragments \$(builddir)/target/$ddtrace_cargo_profile/libddtrace_php.a: $( (find "$ext_srcdir/components-rs" -name "*.c" -o -name "*.rs" -o -name "Cargo.toml"; find "$ext_srcdir/../../libdatadog" -name "*.rs" -not -path "*/target/*"; find "$ext_srcdir/libdatadog" -name "*.rs" -not -path "*/target/*"; echo "$all_object_files" ) 2>/dev/null | xargs ) - (cd "$ext_srcdir/components-rs"; $ddtrace_mock_sources CARGO_TARGET_DIR=\$(builddir)/target/ RUSTFLAGS="${RUSTFLAGS:-} --cfg tokio_unstable --cfg tokio_taskdump" RUSTC_BOOTSTRAP=1 \$(DDTRACE_CARGO) build $(test "$ddtrace_cargo_profile" == debug || echo --profile tracer-release) \$(shell echo "\$(MAKEFLAGS)" | $EGREP -o "[[-]]j[[0-9]]+") && test "$PHP_DDTRACE_RUST_SYMBOLS" == yes || strip -d \$(builddir)/target/$ddtrace_cargo_profile/libddtrace_php.a) + (cd "$ext_srcdir/components-rs"; $ddtrace_mock_sources CARGO_TARGET_DIR=\$(builddir)/target/ RUSTFLAGS="${RUSTFLAGS:-} --cfg tokio_unstable $([[ $host_os == linux* ]] && echo "--cfg tokio_taskdump")" RUSTC_BOOTSTRAP=1 \$(DDTRACE_CARGO) build $(test "$ddtrace_cargo_profile" == debug || echo --profile tracer-release) \$(shell echo "\$(MAKEFLAGS)" | $EGREP -o "[[-]]j[[0-9]]+") && test "$PHP_DDTRACE_RUST_SYMBOLS" == yes || strip -d \$(builddir)/target/$ddtrace_cargo_profile/libddtrace_php.a) EOT if test "$ext_shared" = "shared" || test "$ext_shared" = "yes"; then diff --git a/ext/logging.c b/ext/logging.c index e1eca7e7eb..bd565caafa 100644 --- a/ext/logging.c +++ b/ext/logging.c @@ -43,7 +43,7 @@ void ddtrace_log_minit(void) { } } - ddtrace_log_ginit(); + // no need to call dd_log_set_level here, ddtrace_config_minit() inits the debug config } void ddtrace_log_rinit(char *error_log) { diff --git a/ext/random.c b/ext/random.c index 0ff8b5e33a..3dc7aca3cf 100644 --- a/ext/random.c +++ b/ext/random.c @@ -3,8 +3,12 @@ #include #include +#if PHP_VERSION_ID < 80400 #include #include +#else +#include +#endif #include "configuration.h" #include "ddtrace.h" diff --git a/libdatadog b/libdatadog index 5cb01c5c0e..7c1ebf4ed5 160000 --- a/libdatadog +++ b/libdatadog @@ -1 +1 @@ -Subproject commit 5cb01c5c0efc9d36896b1c641209747441d08fec +Subproject commit 7c1ebf4ed53bd5c05cbf98c0f3cdf54aa01e7a38 diff --git a/zend_abstract_interface/uri_normalization/uri_normalization.c b/zend_abstract_interface/uri_normalization/uri_normalization.c index 2a78606288..40e0666db1 100644 --- a/zend_abstract_interface/uri_normalization/uri_normalization.c +++ b/zend_abstract_interface/uri_normalization/uri_normalization.c @@ -24,6 +24,14 @@ static inline zend_string *zai_php_pcre_replace(zend_string *regex, zend_string php_pcre_replace(regex, subj, subjstr, subjlen, replace, limit, (int *)replacements) #endif +#if PHP_VERSION_ID < 80400 +#if PHP_VERSION_ID < 70400 +#define php_pcre_match_impl(pce, subject_str, return_value, subpats, global, flags, start_offset) php_pcre_match_impl(pce, ZSTR_VAL(subject_str), ZSTR_LEN(subject_str), return_value, subpats, global != 0, 0, flags, start_offset) +#else +#define php_pcre_match_impl(pce, subject_str, return_value, subpats, global, flags, start_offset) php_pcre_match_impl(pce, subject_str, return_value, subpats, global != 0, 0, flags, start_offset) +#endif +#endif + static zend_bool zai_starts_with_protocol(zend_string *str) { // See: https://tools.ietf.org/html/rfc3986#page-17 if (ZSTR_VAL(str)[0] < 'a' || ZSTR_VAL(str)[0] > 'z') { @@ -229,11 +237,7 @@ bool zai_match_regex(zend_string *pattern, zend_string *subject) { } zval ret; -#if PHP_VERSION_ID < 70400 - php_pcre_match_impl(pce, ZSTR_VAL(subject), ZSTR_LEN(subject), &ret, NULL, 0, 0, 0, 0); -#else - php_pcre_match_impl(pce, subject, &ret, NULL, 0, 0, 0, 0); -#endif + php_pcre_match_impl(pce, subject, &ret, NULL, 0, 0, 0); zend_string_release(regex); return Z_TYPE(ret) == IS_LONG && Z_LVAL(ret) > 0; }