Skip to content

Commit

Permalink
Fix PHP 8.4 / macos build
Browse files Browse the repository at this point in the history
Signed-off-by: Bob Weinand <[email protected]>
  • Loading branch information
bwoebi committed Jan 30, 2024
1 parent 958f0f2 commit 24274c0
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 8 deletions.
2 changes: 1 addition & 1 deletion config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ if test "$PHP_DDTRACE" != "no"; then

cat <<EOT >> 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
Expand Down
2 changes: 1 addition & 1 deletion ext/logging.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 4 additions & 0 deletions ext/random.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@
#include <php.h>
#include <stdlib.h>

#if PHP_VERSION_ID < 80400
#include <ext/standard/php_rand.h>
#include <ext/standard/php_random.h>
#else
#include <ext/random/php_random.h>
#endif

#include "configuration.h"
#include "ddtrace.h"
Expand Down
2 changes: 1 addition & 1 deletion libdatadog
14 changes: 9 additions & 5 deletions zend_abstract_interface/uri_normalization/uri_normalization.c
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down Expand Up @@ -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;
}

0 comments on commit 24274c0

Please sign in to comment.