php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #77901 declare tick is now local for each PHP file
Submitted: 2019-04-15 16:26 UTC Modified: 2019-04-17 10:14 UTC
From: lyrixx at lyrixx dot info Assigned: cmb (profile)
Status: Closed Package: *General Issues
PHP Version: 7.0 OS: all
Private report: No CVE-ID: None
 [2019-04-15 16:26 UTC] lyrixx at lyrixx dot info
Description:
------------
Hello,

I'm usually using https://gist.github.com/lyrixx/17074868cdfabd4c783e
to find segfault, or line that hang.

But, as of PHP 7.0 this does not work anymore because it seems declare tick is now local for each PHP file.

I check in https://www.php.net/manual/en/migration70.php But I could not find any mention to this BC breack.

Test script:
---------------
------------------
<?php
// File a.php:
register_tick_function(function() {
    $bt = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 1);
    $last = reset($bt);
    $info = sprintf("%s +%d\n", $last['file'], $last['line']);
    file_put_contents('php://output', $info, FILE_APPEND);
});

declare(ticks=1);

function foobar()
{
    $c = 1;
}

require __DIR__.'/b.php';

foobar();
------------------
<?php
// File b.php:
function bingo()
{
    $e = 1;
}

bingo();
------------------

Then 
* docker run -it --rm -v $(pwd):/app  php:5.6 php /app/a.php
* docker run -it --rm -v $(pwd):/app  php:7.0 php /app/a.php

Expected result:
----------------
The same output for PHP 5.6 and PHP 7.0:

/app/a.php +9
/app/a.php +14
/app/b.php +6
/app/b.php +5
/app/b.php +8
/app/a.php +16
/app/a.php +13
/app/a.php +18


Actual result:
--------------
/app/a.php +9
/app/a.php +14
/app/a.php +16
/app/a.php +13
/app/a.php +18


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-04-15 16:46 UTC] requinix@php.net
-Status: Open +Status: Verified -Type: Bug +Type: Documentation Problem -PHP Version: 7.1.28 +PHP Version: 7.0
 [2019-04-15 16:46 UTC] requinix@php.net
declare(ticks); was never supposed to affect other files than the one the directive is used in. See bug #71448.

The declare docs and migration guide should mention the change.
 [2019-04-17 10:13 UTC] cmb@php.net
Automatic comment from SVN on behalf of cmb
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=347260
Log: Fix #77901: declare tick is now local for each PHP file
 [2019-04-17 10:14 UTC] cmb@php.net
-Status: Verified +Status: Closed -Assigned To: +Assigned To: cmb
 [2019-04-17 10:14 UTC] cmb@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.
 [2019-04-17 10:15 UTC] salathe@php.net
Automatic comment on behalf of cmb
Revision: http://git.php.net/?p=doc/en.git;a=commit;h=12c45bc587695ad12ad8bfc5d57f6661d409c187
Log: Fix #77901: declare tick is now local for each PHP file
 [2020-02-07 06:05 UTC] phpdocbot@php.net
Automatic comment on behalf of cmb
Revision: http://git.php.net/?p=doc/en.git;a=commit;h=b20fb5e69d7f7a91a52e43bbb95925893cbd4bb9
Log: Fix #77901: declare tick is now local for each PHP file
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 20:01:29 2024 UTC