[php-src] Issue #8960: Tick function doesn't work inside Fibers

From: Date: Sat, 09 Jul 2022 10:38:44 +0000
Subject: [php-src] Issue #8960: Tick function doesn't work inside Fibers
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-241888@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/8960 Author: Alimadadi ### Description The following code: ```php <?php declare(ticks=1); register_tick_function(function(){ if(Fiber::getCurrent() !== null) { Fiber::suspend(); } }); for($i = 3; $i--;) { $fibers[$i] = new fiber(function (){ echo "1\n"; echo "2\n"; echo "3\n"; }); $fibers[$i]->start(); } ``` Resulted in this output: ``` 1 1 2 3 1 2 3 ``` But I expected this output instead: ``` 1 1 1 ``` Explanation: If we are inside a fiber, after each tick, the tick function should call Fiber::suspend(). But currently this tick function only works inside first Fiber. ### PHP Version PHP 8.1.8 ### Operating System macOS

« previous php.bugs (#241888) next »