Edit report at https://bugs.php.net/bug.php?id=78218&edit=1
ID: 78218
Updated by: cmb@php.net
Reported by: lozinskiy dot artem at gmail dot com
Summary: function intercepts execution of code that is not
executed
-Status: Re-Opened
+Status: Feedback
Type: Documentation Problem
Package: Unknown/Other Function
Operating System: Ubuntu 18.04 LTS
PHP Version: 7.1.30
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
PHP 7.1 is no longer actively supported[1] (it receives only
security fixes). Does this issue also happen with any actively
supported PHP version?
[1] <https://www.php.net/supported-versions.php>
Previous Comments:
------------------------------------------------------------------------
[2019-06-26 15:28:17] lozinskiy dot artem at gmail dot com
for example see this code
<?php
declare(ticks=1);
function my_function() {
echo print_r(debug_backtrace(), 1) . '<br/>';
}
register_tick_function('my_function', true);
$t = false;
$check = ['a'];
foreach ($check as $e) {
$t = false;
if ($t===false) {
break; // break;
} else {
delete_db(); // =)
}
}
function delete_db() {}
---
analysis show me that execute delete_db, and this is problem
I see that in the alpha version of php 7.4 there is no such problem, all of a sudden, it pleases,
here now to get a patch for php 7.1
------------------------------------------------------------------------
[2019-06-26 14:56:08] lozinskiy dot artem at gmail dot com
>> Whatever the actual magical process is behind ticks, I don't think there's a bug
>> here.
Seriously, I made a convenient code analysis for myself using this function, but because of this
there is no bug, as you said, I cannot trust this analysis, for me this is a bug and a problem,
besides, only here is this behavior, and how can catch or identify this moment? How can I determine
that the function has been correctly reversed here and not here?
------------------------------------------------------------------------
[2019-06-26 14:48:49] requinix@php.net
Whatever the actual magical process is behind ticks, I don't think there's a bug here.
Look at https://3v4l.org/hneib/vld#output to see
exactly what PHP is doing with the code.
------------------------------------------------------------------------
[2019-06-26 14:30:39] lozinskiy dot artem at gmail dot com
But why on line 30 this function executed?
After all, up to 30 lines the cycle must be completed and the code will not be executed further.
------------------------------------------------------------------------
[2019-06-26 14:14:27] requinix@php.net
Because the very first thing that happens when execution enters the function is that execution
immediately leaves the function. And as documented, "not all statements are tickable".
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=78218
--
Edit this bug report at https://bugs.php.net/bug.php?id=78218&edit=1