Skip to content

Commit a13e487

Browse files
committed
Merged pull request #1051
* pr/1051: PHP 8.6: printf() is now optimised out if it only uses %s and %d (and literals) PHP 8.6: The object IDs of objects changed in tests PHP 8.6: ZSTR_INIT_LITERAL() no longer takes non-literals, so use zend_string_init() PHP 8.6: WRONG_PARAM_COUNT has been removed in favour of zend_wrong_param_count() + RETURN_THROWS() PHP 8.6: zval_dtor() has been deprecated in favour of zval_ptr_dtor_nogc()
2 parents 68c8a64 + 2f5a05d commit a13e487

File tree

10 files changed

+31
-28
lines changed

10 files changed

+31
-28
lines changed

src/base/base.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ int xdebug_include_or_eval_handler(XDEBUG_OPCODE_HANDLER_ARGS)
192192
XG_BASE(last_eval_statement) = zend_string_init(Z_STRVAL_P(inc_filename), Z_STRLEN_P(inc_filename), 0);
193193

194194
if (inc_filename == &tmp_inc_filename) {
195-
zval_dtor(&tmp_inc_filename);
195+
zval_ptr_dtor_nogc(&tmp_inc_filename);
196196
}
197197

198198
return xdebug_call_original_opcode_handler_if_set(opline->opcode, XDEBUG_OPCODE_HANDLER_ARGS_PASSTHRU);

src/debugger/debugger.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ void xdebug_debugger_statement_call(zend_string *filename, int lineno)
467467
res = xdebug_do_eval(extra_brk_info->condition, &retval, NULL);
468468
if (res) {
469469
break_ok = Z_TYPE(retval) == IS_TRUE;
470-
zval_dtor(&retval);
470+
zval_ptr_dtor_nogc(&retval);
471471
}
472472
}
473473
if (break_ok && xdebug_handle_hit_value(extra_brk_info)) {

src/debugger/handler_dbgp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1937,7 +1937,7 @@ DBGP_FUNC(property_set)
19371937
/* don't send an error, send success = zero */
19381938
xdebug_xml_add_attribute(*retval, "success", "0");
19391939
} else {
1940-
zval_dtor(&ret_zval);
1940+
zval_ptr_dtor_nogc(&ret_zval);
19411941
xdebug_xml_add_attribute(*retval, "success", "1");
19421942
}
19431943
}

src/develop/php_functions.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ PHP_FUNCTION(xdebug_var_dump)
4747
args = safe_emalloc(argc, sizeof(zval), 0);
4848
if (ZEND_NUM_ARGS() == 0 || zend_get_parameters_array_ex(argc, args) == FAILURE) {
4949
efree(args);
50-
WRONG_PARAM_COUNT;
50+
zend_wrong_param_count();
51+
RETURN_THROWS();
5152
}
5253

5354
for (i = 0; i < argc; i++) {
@@ -86,7 +87,8 @@ PHP_FUNCTION(xdebug_debug_zval)
8687
args = safe_emalloc(argc, sizeof(zval), 0);
8788
if (ZEND_NUM_ARGS() == 0 || zend_get_parameters_array_ex(argc, args) == FAILURE) {
8889
efree(args);
89-
WRONG_PARAM_COUNT;
90+
zend_wrong_param_count();
91+
RETURN_THROWS();
9092
}
9193

9294
if (!(ZEND_CALL_INFO(EG(current_execute_data)->prev_execute_data) & ZEND_CALL_HAS_SYMBOL_TABLE)) {
@@ -151,7 +153,8 @@ PHP_FUNCTION(xdebug_debug_zval_stdout)
151153
args = safe_emalloc(argc, sizeof(zval), 0);
152154
if (ZEND_NUM_ARGS() == 0 || zend_get_parameters_array_ex(argc, args) == FAILURE) {
153155
efree(args);
154-
WRONG_PARAM_COUNT;
156+
zend_wrong_param_count();
157+
RETURN_THROWS();
155158
}
156159

157160
if (!(ZEND_CALL_INFO(EG(current_execute_data)->prev_execute_data) & ZEND_CALL_HAS_SYMBOL_TABLE)) {

src/profiler/profiler.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ void xdebug_profiler_add_function_details_user(function_stack_entry *fse, zend_o
354354
} else {
355355
fse->profiler.filename = zend_string_copy(fse->filename);
356356
}
357-
fse->profiler.function = ZSTR_INIT_LITERAL(tmp_name, false);
357+
fse->profiler.function = zend_string_init(tmp_name, strlen(tmp_name), false);
358358
xdfree(tmp_name);
359359
}
360360

@@ -383,7 +383,7 @@ void xdebug_profiler_add_function_details_internal(function_stack_entry *fse)
383383
}
384384

385385
fse->profiler.filename = zend_string_copy(fse->filename);
386-
fse->profiler.function = ZSTR_INIT_LITERAL(tmp_name, false);
386+
fse->profiler.function = zend_string_init(tmp_name, strlen(tmp_name), false);
387387

388388
xdfree(tmp_name);
389389
}

tests/develop/bug01996-002-ansi-php82.phpt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ var_dump($closure);
3333
?>
3434
--EXPECTF--
3535
%sbug01996-002-ansi-php82.php:3:
36-
[1mclass[22m [31mClosure[0m#1 ([32m2[0m) {
36+
[1mclass[22m [31mClosure[0m#%d ([32m2[0m) {
3737
public $function =>
3838
string(6) "substr"
3939
public $parameter =>
@@ -47,7 +47,7 @@ var_dump($closure);
4747
}
4848
}
4949
%sbug01996-002-ansi-php82.php:11:
50-
[1mclass[22m [31mClosure[0m#2 ([32m2[0m) {
50+
[1mclass[22m [31mClosure[0m#%d ([32m2[0m) {
5151
public $function =>
5252
string(12) "user_defined"
5353
public $parameter =>
@@ -59,7 +59,7 @@ var_dump($closure);
5959
}
6060
}
6161
%sbug01996-002-ansi-php82.php:15:
62-
[1mclass[22m [31mClosure[0m#1 ([32m2[0m) {
62+
[1mclass[22m [31mClosure[0m#%d ([32m2[0m) {
6363
public $function =>
6464
string(35) "DateTimeImmutable::createFromFormat"
6565
public $parameter =>
@@ -73,11 +73,11 @@ var_dump($closure);
7373
}
7474
}
7575
%sbug01996-002-ansi-php82.php:20:
76-
[1mclass[22m [31mClosure[0m#3 ([32m3[0m) {
76+
[1mclass[22m [31mClosure[0m#%d ([32m3[0m) {
7777
public $function =>
7878
string(25) "DateTimeImmutable::format"
7979
public $this =>
80-
[1mclass[22m [31mDateTimeImmutable[0m#2 ([32m3[0m) {
80+
[1mclass[22m [31mDateTimeImmutable[0m#%d ([32m3[0m) {
8181
public $date =>
8282
string(26) "2021-07-22 00:00:00.000000"
8383
public $timezone_type =>

tests/develop/bug01996-002-html-php82.phpt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ var_dump($closure);
3434
--EXPECTF--
3535
<pre class='xdebug-var-dump' dir='ltr'>
3636
<small>%sbug01996-002-html-php82.php:3:</small>
37-
<b>object</b>(<i>Closure</i>)[<i>1</i>]
37+
<b>object</b>(<i>Closure</i>)[<i>%d</i>]
3838
<i>virtual</i> 'closure' <font color='#cc0000'>'substr'</font>
3939
<i>public</i> 'function' <font color='#888a85'>=&gt;</font> <small>string</small> <font color='#cc0000'>'substr'</font> <i>(length=6)</i>
4040
<i>public</i> 'parameter' <font color='#888a85'>=&gt;</font>
@@ -44,7 +44,7 @@ var_dump($closure);
4444
'$length' <font color='#888a85'>=&gt;</font> <small>string</small> <font color='#cc0000'>'&lt;optional&gt;'</font> <i>(length=10)</i>
4545
</pre><pre class='xdebug-var-dump' dir='ltr'>
4646
<small>%sbug01996-002-html-php82.php:11:</small>
47-
<b>object</b>(<i>Closure</i>)[<i>2</i>]
47+
<b>object</b>(<i>Closure</i>)[<i>%d</i>]
4848
<i>virtual</i> 'closure' <font color='#cc0000'>'user_defined'</font>
4949
<i>public</i> 'function' <font color='#888a85'>=&gt;</font> <small>string</small> <font color='#cc0000'>'user_defined'</font> <i>(length=12)</i>
5050
<i>public</i> 'parameter' <font color='#888a85'>=&gt;</font>
@@ -53,7 +53,7 @@ var_dump($closure);
5353
'$b' <font color='#888a85'>=&gt;</font> <small>string</small> <font color='#cc0000'>'&lt;required&gt;'</font> <i>(length=10)</i>
5454
</pre><pre class='xdebug-var-dump' dir='ltr'>
5555
<small>%sbug01996-002-html-php82.php:15:</small>
56-
<b>object</b>(<i>Closure</i>)[<i>1</i>]
56+
<b>object</b>(<i>Closure</i>)[<i>%d</i>]
5757
<i>virtual</i> 'closure' <font color='#cc0000'>'DateTimeImmutable::createFromFormat'</font>
5858
<i>public</i> 'function' <font color='#888a85'>=&gt;</font> <small>string</small> <font color='#cc0000'>'DateTimeImmutable::createFromFormat'</font> <i>(length=35)</i>
5959
<i>public</i> 'parameter' <font color='#888a85'>=&gt;</font>
@@ -63,11 +63,11 @@ var_dump($closure);
6363
'$timezone' <font color='#888a85'>=&gt;</font> <small>string</small> <font color='#cc0000'>'&lt;optional&gt;'</font> <i>(length=10)</i>
6464
</pre><pre class='xdebug-var-dump' dir='ltr'>
6565
<small>%sbug01996-002-html-php82.php:20:</small>
66-
<b>object</b>(<i>Closure</i>)[<i>3</i>]
66+
<b>object</b>(<i>Closure</i>)[<i>%d</i>]
6767
<i>virtual</i> 'closure' <font color='#cc0000'>'$this->format'</font>
6868
<i>public</i> 'function' <font color='#888a85'>=&gt;</font> <small>string</small> <font color='#cc0000'>'DateTimeImmutable::format'</font> <i>(length=25)</i>
6969
<i>public</i> 'this' <font color='#888a85'>=&gt;</font>
70-
<b>object</b>(<i>DateTimeImmutable</i>)[<i>2</i>]
70+
<b>object</b>(<i>DateTimeImmutable</i>)[<i>%d</i>]
7171
<i>public</i> 'date' <font color='#888a85'>=&gt;</font> <small>string</small> <font color='#cc0000'>'2021-07-22 00:00:00.000000'</font> <i>(length=26)</i>
7272
<i>public</i> 'timezone_type' <font color='#888a85'>=&gt;</font> <small>int</small> <font color='#4e9a06'>3</font>
7373
<i>public</i> 'timezone' <font color='#888a85'>=&gt;</font> <small>string</small> <font color='#cc0000'>'UTC'</font> <i>(length=3)</i>

tests/develop/bug01996-002-text-php82.phpt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ var_dump($closure);
3333
?>
3434
--EXPECTF--
3535
%sbug01996-002-text-php82.php:3:
36-
class Closure#1 (2) {
36+
class Closure#%d (2) {
3737
public $function =>
3838
string(6) "substr"
3939
public $parameter =>
@@ -47,7 +47,7 @@ class Closure#1 (2) {
4747
}
4848
}
4949
%sbug01996-002-text-php82.php:11:
50-
class Closure#2 (2) {
50+
class Closure#%d (2) {
5151
public $function =>
5252
string(12) "user_defined"
5353
public $parameter =>
@@ -59,7 +59,7 @@ class Closure#2 (2) {
5959
}
6060
}
6161
%sbug01996-002-text-php82.php:15:
62-
class Closure#1 (2) {
62+
class Closure#%d (2) {
6363
public $function =>
6464
string(35) "DateTimeImmutable::createFromFormat"
6565
public $parameter =>
@@ -73,11 +73,11 @@ class Closure#1 (2) {
7373
}
7474
}
7575
%sbug01996-002-text-php82.php:20:
76-
class Closure#3 (3) {
76+
class Closure#%d (3) {
7777
public $function =>
7878
string(25) "DateTimeImmutable::format"
7979
public $this =>
80-
class DateTimeImmutable#2 (3) {
80+
class DateTimeImmutable#%d (3) {
8181
public $date =>
8282
string(26) "2021-07-22 00:00:00.000000"
8383
public $timezone_type =>

tests/tracing/bug00003.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ date.timezone=Europe/Oslo
1010
--FILE--
1111
<?php
1212
require_once 'capture-trace.inc';
13-
@printf('%d %d %d %d:%d:%d', 1061728888, 1061728888, 1061728888, 1061728888, 1061728888, 1061728888);
13+
@printf('%d %d %d %d:%d:%x', 1061728888, 1061728888, 1061728888, 1061728888, 1061728888, 1061728888);
1414
xdebug_stop_trace();
1515
?>
1616
--EXPECTF--

tests/tracing/bug00558-002.phpt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,19 @@ xdebug.trace_format=0
1010
<?php
1111
require_once 'capture-trace.inc';
1212

13-
$any = 'printf("foo\n");';
13+
$any = 'printf("foo: %x\n", 42);';
1414
eval('eval($any);');
1515

1616
xdebug_stop_trace();
1717
?>
1818
DONE
1919
--EXPECTF--
20-
foo
20+
foo: 2a
2121
DONE
2222
TRACE START [%d-%d-%d %d:%d:%d.%d]
2323
%w%f %w%d -> eval('eval($any);') %sbug00558-002.php:5
24-
%w%f %w%d -> eval('printf("foo\\n");') %sbug00558-002.php(5) : eval()'d code:1
25-
%w%f %w%d -> printf($format = 'foo\n') %sbug00558-002.php(5) : eval()'d code(1) : eval()'d code:1
24+
%w%f %w%d -> eval('printf("foo: %s\\n", 42);') %sbug00558-002.php(5) : eval()'d code:1
25+
%w%f %w%d -> printf($format = 'foo: %s\n', ...$values = variadic(0 => 42)) %sbug00558-002.php(5) : eval()'d code(1) : eval()'d code:1
2626
%w%f %w%d -> xdebug_stop_trace() %sbug00558-002.php:7
2727
%w%f %w%d
2828
TRACE END [%d-%d-%d %d:%d:%d.%d]

0 commit comments

Comments
 (0)