php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74712 Now have to redeclare ticks on every file in PHP 7
Submitted: 2017-06-08 16:38 UTC Modified: 2017-06-08 22:27 UTC
From: hello at peterfeatherstone dot com Assigned:
Status: Duplicate Package: Scripting Engine problem
PHP Version: Irrelevant OS: Ubuntu 17.04
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: hello at peterfeatherstone dot com
New email:
PHP Version: OS:

 

 [2017-06-08 16:38 UTC] hello at peterfeatherstone dot com
Description:
------------
In PHP 5.6 it seems that adding declare(ticks=1) and then using register_tick_function() would follow any includes and provide profiling information accordingly.

In PHP 7+ however it now seems I have to add declare(ticks=1) in every file. I use this for profiling every method call on a page load and can't now add this to each PHP file in my system (If they are in libraries etc.).

I can't find anything in the docs about changes that were made to this or an alternative method for profiling every tick in the application.

Test script:
---------------
Replication code can be found here - https://stackoverflow.com/questions/44440613/how-to-avoid-redeclaring-ticks-on-every-file-in-php-7?noredirect=1#comment75879747_44440613

Expected result:
----------------
Running php index.php I would expect to see 7

Actual result:
--------------
In PHP 5.6 I see 7 as expected
In PHP 7 I see 5

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-06-08 16:43 UTC] peehaa@php.net
Please add the repro code on here instead of having to hunt for it on an external site with the possibility of the link going down.
 [2017-06-08 16:49 UTC] hello at peterfeatherstone dot com
Sure, no problem - although your recommendations say to link externally if its pver 20 lines so I couldnt paste it...
 [2017-06-08 16:53 UTC] hello at peterfeatherstone dot com
Replication code:

index.php

<?php

declare(ticks=1);
$count = 0;

register_tick_function('ticker');
function ticker() {
  global $count;
  $count++;
}

$foo = 'foo';
$bar = 'bar';

include dirname(__FILE__) . '/inc.php';

echo $count;

inc.php

$baz = "baz";
$qux = "qux";
 [2017-06-08 22:27 UTC] requinix@php.net
-Status: Open +Status: Duplicate
 [2017-06-08 22:27 UTC] requinix@php.net
Duplicate of bug #71448, which has an explanation by @nikic.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Nov 22 02:01:28 2024 UTC