MantisBT

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0001540XdebugCode Coveragepublic2018-03-26 15:312018-12-28 09:06
Reportertheoboldt 
Assigned Toderick 
PrioritynormalSeveritymajorReproducibilityalways
StatusassignedResolutionopen 
PlatformLinuxOSUbuntuOS Version16.04.1
Product Version2.6.0 
Target VersionFixed in Version 
Summary0001540: Multiline class instantiate within method call is not covered when using php-fpm
DescriptionWhen instantiating a class within a method call and the variables for the new object are passed in separate lines, the lines containing the parameters are not marked as covered when php is executed by FPM. The lines are marked as covered as expected when the same file is executed via CLI using same php/xdebug version.

//TEST
class A {
    public function b($a, $b, $c, $d) {
        return new B(
            $a,
            $b,
            $c,
            $d
        );
    }
}

class B {
    public function __construct($a, $b, $c, bool $d) { }
}

xdebug_start_code_coverage(XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE);
$a        = new A();
$b        = $a->b(
    'a',
    'b',
    'c',
    'd'
);
$coverage = xdebug_get_code_coverage();
xdebug_stop_code_coverage();


//EVALUATE (not part of proof)
print_r(
    [
        'phpversion(\'xdebug\')' => phpversion('xdebug'),
        'phpversion()'           => phpversion(),
        'php_sapi_name()'        => php_sapi_name()
    ]
);
print_r($coverage);


When executing above code via CLI, following output is generated:
Array
(
    [phpversion('xdebug')] => 2.6.0
    [phpversion()] => 7.0.28-0ubuntu0.16.04.1
    [php_sapi_name()] => cli
)
Array
(
    [/intproj/users/erik/xdebug_coverage_issues/multiline_class_instantiate.php] => Array
        (
            [11] => 1
            [12] => 1
            [13] => 1
            [14] => 1
            [15] => 1
            [21] => 1
            [25] => 1
            [26] => 1
            [27] => 1
            [28] => 1
            [29] => 1
            [30] => 1
            [32] => 1
        )
)


When executing above code via Apache 2 (Server API: FPM/FastCGI, PHP API: 20151012, PHP Extension: 20151012) the output differs significantly for line 12, 13, 14, 15:
Array
(
    [phpversion('xdebug')] => 2.6.0
    [phpversion()] => 7.0.28-0ubuntu0.16.04.1
    [php_sapi_name()] => fpm-fcgi
)
Array
(
    [/intproj/users/erik/xdebug_coverage_issues/multiline_class_instantiate.php] => Array
        (
            [11] => 1
            [12] => -1
            [13] => -1
            [14] => -1
            [15] => -1
            [21] => 1
            [25] => 1
            [26] => 1
            [30] => 1
            [32] => 1
        )
)
Steps To ReproduceExecute provided snipped via php-fpm and via cli as well, compare results
TagsPHP7
Operating Systemubuntu0.16.04.1
PHP Version7.0.25-7.0.29
Attached Files? file icon multiline_class_instantiate.php [^] (838 bytes) 2018-03-26 15:31
html file icon phpinfo_fpm.html [^] (113,225 bytes) 2018-12-28 08:57
html file icon phpinfo_built-in-server.html [^] (105,398 bytes) 2018-12-28 08:57
txt file icon phpinfo_cli.txt [^] (37,760 bytes) 2018-12-28 08:57 [Show Content]

- Relationships

-  Notes
(0004723)
theoboldt (reporter)
2018-11-15 10:54

Still reproducible using xdebug 2.6.1.
(0004751)
theoboldt (reporter)
2018-12-06 15:27

Reproducible also having opcache disabled:
{code}
Array
(
    [phpversion('xdebug')] => 2.6.0
    [phpversion()] => 7.0.32-0ubuntu0.16.04.1
    [php_sapi_name()] => fpm-fcgi
)
Array
(
    [/intproj/users/erik/multiline_class_instantiate.php] => Array
        (
            [11] => 1
            [12] => -1
            [13] => -1
            [14] => -1
            [15] => -1
            [17] => -2
            [21] => 1
            [25] => 1
            [26] => 1
            [30] => 1
            [32] => 1
        )
)
{code}
(0004752)
theoboldt (reporter)
2018-12-06 15:33
edited on: 2018-12-28 09:06

Also reproducible using php 7.2:

opcache enabled:
{code}
Array
(
    [phpversion('xdebug')] => 2.6.0
    [phpversion()] => 7.2.10-0ubuntu0.18.04.1
    [php_sapi_name()] => fpm-fcgi
)
Array
(
    [/intproj/users/erik/multiline_class_instantiate.php] => Array
        (
            [11] => 1
            [12] => -1
            [13] => -1
            [14] => -1
            [15] => -1
            [21] => 1
            [25] => 1
            [26] => 1
            [30] => 1
            [32] => 1
        )
)
{code}

opcache disabled:
{code}
Array
(
    [phpversion('xdebug')] => 2.6.0
    [phpversion()] => 7.2.10-0ubuntu0.18.04.1
    [php_sapi_name()] => fpm-fcgi
)
Array
(
    [/intproj/users/erik/multiline_class_instantiate.php] => Array
        (
            [11] => 1
            [12] => -1
            [13] => -1
            [14] => -1
            [15] => -1
            [17] => -2
            [21] => 1
            [25] => 1
            [26] => 1
            [30] => 1
            [32] => 1
        )
)
{code}

(0004780)
derick (administrator)
2018-12-23 21:12

I'm going to have to try this, but I'm pretty certain it's a similar issue as what I explained in this blog article: https://derickrethans.nl/breakpoints.html [^]
(0004785)
theoboldt (reporter)
2018-12-27 15:42

Good to hear that there might be a solution some day!

Just besides - I've no idea why the uploads except "multiline_class_instantiate.php" were added - I don't assume that any document or archive is helpful here. It's much likelier that they do have hazardous contents.
(0004786)
derick (administrator)
2018-12-27 18:35

I've tried reproducing this, but I'm not having any luck. Would you mind adding phpinfo() output for both the CLI *and* PHP-FPM variants with the same PHP version (like in your original report). With as only change using -dhtml_errors=1 to the CLI variant, so that its phpinfo() output is also in HTML? (That makes it easier to diff them for me).
(0004789)
theoboldt (reporter)
2018-12-28 09:05

I added the phpinfo() outputs as files. Unfortunately, although I was successfully able to enable `html_errors=1`, the output still wasn't wrapped by html. I added the textual phpinfo() output as well.

I also executed the phpinfo script with the built in HTTP server, which also uses the cli php configuration (possibly with some variations you might be more aware of). This environment is also not affected by the issue (as the cli isn't as well):

{code}

Array
(
    [phpversion('xdebug')] => 2.6.0
    [phpversion()] => 7.0.32-0ubuntu0.16.04.1
    [php_sapi_name()] => cli-server
)
Array
(
    [/intproj/users/erik/multiline_class_instantiate.php] => Array
        (
            [11] => 1
            [12] => 1
            [13] => 1
            [14] => 1
            [15] => 1
            [21] => 1
            [25] => 1
            [26] => 1
            [27] => 1
            [28] => 1
            [29] => 1
            [30] => 1
            [32] => 1
        )
)
{code}

- Issue History
Date Modified Username Field Change
2018-03-26 15:31 theoboldt New Issue
2018-03-26 15:31 theoboldt File Added: multiline_class_instantiate.php
2018-03-26 15:48 theoboldt Tag Attached: PHP7
2018-11-15 10:54 theoboldt Note Added: 0004723
2018-12-03 13:18 Markus34 File Added: 512.pdf
2018-12-06 15:27 theoboldt Note Added: 0004751
2018-12-06 15:33 theoboldt Note Added: 0004752
2018-12-06 15:33 theoboldt Note Edited: 0004752 View Revisions
2018-12-07 08:46 Markus34 File Added: 514.gz
2018-12-07 08:57 Markus34 File Added: 515.gz
2018-12-17 09:40 Markus34 Note Added: 0004771
2018-12-17 09:40 Markus34 Note Edited: 0004771 View Revisions
2018-12-17 09:54 Markus34 Note Edited: 0004771 View Revisions
2018-12-23 21:12 derick Note Added: 0004780
2018-12-23 21:12 derick Assigned To => derick
2018-12-23 21:12 derick Status new => acknowledged
2018-12-27 15:42 theoboldt Note Added: 0004785
2018-12-27 18:19 derick Note Deleted: 0004771
2018-12-27 18:19 derick File Deleted: 512.pdf
2018-12-27 18:20 derick File Deleted: 515.gz
2018-12-27 18:20 derick File Deleted: 514.gz
2018-12-27 18:23 derick Description Updated View Revisions
2018-12-27 18:24 derick Description Updated View Revisions
2018-12-27 18:35 derick Note Added: 0004786
2018-12-27 18:35 derick Status acknowledged => feedback
2018-12-28 08:57 theoboldt File Added: phpinfo_fpm.html
2018-12-28 08:57 theoboldt File Added: phpinfo_built-in-server.html
2018-12-28 08:57 theoboldt File Added: phpinfo_cli.txt
2018-12-28 09:05 theoboldt Note Added: 0004789
2018-12-28 09:05 theoboldt Status feedback => assigned
2018-12-28 09:06 theoboldt Note Edited: 0004752 View Revisions


Copyright © 2000 - 2019 MantisBT Team
Powered by Mantis Bugtracker