Skip to content

Commit f8ec210

Browse files
committed
Compatible with PHP8.2RC1
#68 Compatible with PHP8.2RC1
1 parent 38e6f97 commit f8ec210

File tree

2 files changed

+35
-2
lines changed

2 files changed

+35
-2
lines changed

extension/php_xhprof.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,14 @@ ZEND_DLEXPORT zend_op_array* hp_compile_string(zval *source_string, char *filena
146146
/* Pointer to the original execute function */
147147
static void (*_zend_execute_ex) (zend_execute_data *execute_data);
148148
ZEND_DLEXPORT void hp_execute_ex (zend_execute_data *execute_data);
149+
#elif PHP_VERSION_ID >= 80200
150+
/* Pointer to the original compile string function (used by eval) */
151+
static zend_op_array * (*_zend_compile_string) (zend_string *source_string, const char *filename, zend_compile_position position);
152+
ZEND_DLEXPORT zend_op_array* hp_compile_string(zend_string *source_string, const char *filename, zend_compile_position position);
153+
154+
static zend_observer_fcall_handlers tracer_observer(zend_execute_data *execute_data);
155+
static void tracer_observer_begin(zend_execute_data *ex);
156+
static void tracer_observer_end(zend_execute_data *ex, zval *return_value);
149157
#else
150158
/* Pointer to the original compile string function (used by eval) */
151159
static zend_op_array * (*_zend_compile_string) (zend_string *source_string, const char *filename);

extension/xhprof.c

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -995,11 +995,23 @@ void hp_mode_sampled_endfn_cb(hp_entry_t **entries)
995995

996996
#if PHP_VERSION_ID >= 80000
997997
static void tracer_observer_begin(zend_execute_data *execute_data) {
998+
#if PHP_VERSION_ID >= 80200
999+
if (execute_data->func->type == ZEND_INTERNAL_FUNCTION) {
1000+
return;
1001+
}
1002+
#endif
1003+
9981004
begin_profiling(NULL, execute_data);
9991005
}
10001006

1001-
static void tracer_observer_end(zend_execute_data *ex, zval *return_value) {
1007+
static void tracer_observer_end(zend_execute_data *execute_data, zval *return_value) {
10021008
if (XHPROF_G(entries)) {
1009+
#if PHP_VERSION_ID >= 80200
1010+
if (execute_data->func->type == ZEND_INTERNAL_FUNCTION) {
1011+
return;
1012+
}
1013+
#endif
1014+
10031015
end_profiling();
10041016
}
10051017
}
@@ -1069,7 +1081,6 @@ ZEND_DLEXPORT void hp_execute_internal(zend_execute_data *execute_data, zval *re
10691081
if (is_profiling == 1 && XHPROF_G(entries)) {
10701082
end_profiling();
10711083
}
1072-
10731084
}
10741085

10751086
/**
@@ -1114,14 +1125,20 @@ ZEND_DLEXPORT zend_op_array* hp_compile_file(zend_file_handle *file_handle, int
11141125
*/
11151126
#if PHP_VERSION_ID < 80000
11161127
ZEND_DLEXPORT zend_op_array* hp_compile_string(zval *source_string, char *filename)
1128+
#elif PHP_VERSION_ID >= 80200
1129+
ZEND_DLEXPORT zend_op_array* hp_compile_string(zend_string *source_string, const char *filename, zend_compile_position position)
11171130
#else
11181131
ZEND_DLEXPORT zend_op_array* hp_compile_string(zend_string *source_string, const char *filename)
11191132
#endif
11201133
{
11211134
int is_profiling = 1;
11221135

11231136
if (!XHPROF_G(enabled)) {
1137+
#if PHP_VERSION_ID >= 80200
1138+
return _zend_compile_string(source_string, filename, position);
1139+
#else
11241140
return _zend_compile_string(source_string, filename);
1141+
#endif
11251142
}
11261143

11271144
zend_string *function_name;
@@ -1130,7 +1147,11 @@ ZEND_DLEXPORT zend_op_array* hp_compile_string(zend_string *source_string, const
11301147
function_name = strpprintf(0, "eval::%s", filename);
11311148

11321149
is_profiling = begin_profiling(function_name, NULL);
1150+
#if PHP_VERSION_ID >= 80200
1151+
op_array = _zend_compile_string(source_string, filename, position);
1152+
#else
11331153
op_array = _zend_compile_string(source_string, filename);
1154+
#endif
11341155

11351156
if (is_profiling == 1 && XHPROF_G(entries)) {
11361157
end_profiling();
@@ -1222,6 +1243,10 @@ static void hp_stop()
12221243

12231244
/* Stop profiling */
12241245
XHPROF_G(enabled) = 0;
1246+
1247+
if (XHPROF_G(root)) {
1248+
zend_string_release(XHPROF_G(root));
1249+
}
12251250
}
12261251

12271252

0 commit comments

Comments
 (0)