Skip to content

Commit da77486

Browse files
authoredJul 9, 2024··
Merge pull request #87 from remicollet/test-php84
Fix for PHP 8.4
2 parents 844e225 + aff62dc commit da77486

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed
 

‎extension/xhprof.c

+11-9
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ void hp_ignored_functions_clear(hp_ignored_functions *functions)
393393
hp_array_del(functions->names);
394394
functions->names = NULL;
395395

396-
memset(functions->filter, 0, XHPROF_MAX_IGNORED_FUNCTIONS);
396+
memset(functions->filter, 0, sizeof(functions->filter));
397397
efree(functions);
398398
}
399399

@@ -425,7 +425,6 @@ hp_ignored_functions *hp_ignored_functions_init(zval *values)
425425

426426
if (Z_TYPE_P(values) == IS_ARRAY) {
427427
HashTable *ht;
428-
zend_ulong num_key;
429428
zend_string *key;
430429
zval *val;
431430

@@ -434,7 +433,7 @@ hp_ignored_functions *hp_ignored_functions_init(zval *values)
434433

435434
names = ecalloc(count + 1, sizeof(zend_string *));
436435

437-
ZEND_HASH_FOREACH_KEY_VAL(ht, num_key, key, val) {
436+
ZEND_HASH_FOREACH_STR_KEY_VAL(ht, key, val) {
438437
if (!key) {
439438
if (Z_TYPE_P(val) == IS_STRING && strcmp(Z_STRVAL_P(val), ROOT_SYMBOL) != 0) {
440439
/* do not ignore "main" */
@@ -457,7 +456,7 @@ hp_ignored_functions *hp_ignored_functions_init(zval *values)
457456
functions = emalloc(sizeof(hp_ignored_functions));
458457
functions->names = names;
459458

460-
memset(functions->filter, 0, XHPROF_MAX_IGNORED_FUNCTIONS);
459+
memset(functions->filter, 0, sizeof(functions->filter));
461460

462461
uint32_t i = 0;
463462
for (; names[i] != NULL; i++) {
@@ -1274,7 +1273,6 @@ static inline void hp_array_del(zend_string **names)
12741273

12751274
int hp_pcre_match(zend_string *pattern, const char *str, size_t len, zend_ulong idx)
12761275
{
1277-
zval *match;
12781276
pcre_cache_entry *pce_regexp;
12791277

12801278
if ((pce_regexp = pcre_get_compiled_regex_cache(pattern)) == NULL) {
@@ -1287,7 +1285,7 @@ int hp_pcre_match(zend_string *pattern, const char *str, size_t len, zend_ulong
12871285
#if PHP_VERSION_ID < 70400
12881286
php_pcre_match_impl(pce_regexp, (char*)str, len, &matches, &subparts /* subpats */,
12891287
0/* global */, 0/* ZEND_NUM_ARGS() >= 4 */, 0/*flags PREG_OFFSET_CAPTURE*/, 0/* start_offset */);
1290-
#else
1288+
#elif PHP_VERSION_ID < 80400
12911289
zend_string *tmp = zend_string_init(str, len, 0);
12921290
php_pcre_match_impl(pce_regexp, tmp, &matches, &subparts /* subpats */,
12931291
0/* global */,
@@ -1296,6 +1294,11 @@ int hp_pcre_match(zend_string *pattern, const char *str, size_t len, zend_ulong
12961294
#endif
12971295
0/*flags PREG_OFFSET_CAPTURE*/, 0/* start_offset */);
12981296
zend_string_release(tmp);
1297+
#else
1298+
zend_string *tmp = zend_string_init(str, len, 0);
1299+
php_pcre_match_impl(pce_regexp, tmp, &matches, &subparts /* subpats */,
1300+
false/* global */, 0/*flags PREG_OFFSET_CAPTURE*/, 0/* start_offset */);
1301+
zend_string_release(tmp);
12991302
#endif
13001303

13011304
if (!zend_hash_num_elements(Z_ARRVAL(subparts))) {
@@ -1352,15 +1355,14 @@ zend_string *hp_trace_callback_pdo_statement_execute(zend_string *symbol, zend_e
13521355
{
13531356
zend_string *result = NULL;
13541357
zend_string *pattern = NULL;
1355-
zend_class_entry *pdo_ce;
13561358
zval *object = (data->This.value.obj) ? &(data->This) : NULL;
13571359
zval *query_string, *arg;
13581360

13591361
if (object != NULL) {
13601362
#if PHP_VERSION_ID < 80000
1361-
query_string = zend_read_property(pdo_ce, object, "queryString", sizeof("queryString") - 1, 0, NULL);
1363+
query_string = zend_read_property(NULL, object, "queryString", sizeof("queryString") - 1, 0, NULL);
13621364
#else
1363-
query_string = zend_read_property(pdo_ce, Z_OBJ_P(object), "queryString", sizeof("queryString") - 1, 0, NULL);
1365+
query_string = zend_read_property(NULL, Z_OBJ_P(object), "queryString", sizeof("queryString") - 1, 0, NULL);
13641366
#endif
13651367

13661368
if (query_string == NULL || Z_TYPE_P(query_string) != IS_STRING) {

0 commit comments

Comments
 (0)
Please sign in to comment.