1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Merge branch 'PHP-8.2' into PHP-8.3

* PHP-8.2:
  Fix handling of nested generator in zend_test observer
This commit is contained in:
Ilija Tovilo
2024-10-22 14:51:58 +02:00
2 changed files with 63 additions and 0 deletions

View File

@@ -20,6 +20,7 @@
#include "zend_observer.h"
#include "zend_smart_str.h"
#include "ext/standard/php_var.h"
#include "zend_generators.h"
static zend_observer_fcall_handlers observer_fcall_init(zend_execute_data *execute_data);
@@ -163,6 +164,11 @@ static void observer_show_init_backtrace(zend_execute_data *execute_data)
zend_execute_data *ex = execute_data;
php_printf("%*s<!--\n", 2 * ZT_G(observer_nesting_depth), "");
do {
if (UNEXPECTED(!ex->func)) {
ex = zend_generator_check_placeholder_frame(ex);
ZEND_ASSERT(ex->func);
}
zend_function *fbc = ex->func;
int indent = 2 * ZT_G(observer_nesting_depth) + 4;
if (fbc->common.function_name) {

View File

@@ -0,0 +1,57 @@
--TEST--
GH-16514: Nested generator in zend_test observer
--EXTENSIONS--
zend_test
--INI--
zend_test.observer.enabled=1
zend_test.observer.show_init_backtrace=1
--FILE--
<?php
class Foo {
public function __destruct() {
debug_print_backtrace();
}
}
function bar() {
yield from foo();
}
function foo() {
$foo = new Foo();
yield;
}
$gen = bar();
foreach ($gen as $dummy);
?>
--EXPECTF--
<!-- init '%sgh16514.php' -->
<!--
{main} %sgh16514.php
-->
<!-- init bar() -->
<!--
bar()
{main} %sgh16514.php
-->
<!-- init foo() -->
<!--
foo()
bar()
{main} %sgh16514.php
-->
<!-- init Foo::__destruct() -->
<!--
Foo::__destruct()
bar()
{main} %sgh16514.php
-->
<!-- init debug_print_backtrace() -->
<!--
debug_print_backtrace()
Foo::__destruct()
bar()
{main} %sgh16514.php
-->
#0 %s(%d): Foo->__destruct()
#1 %s(%d): bar()