wpengine / phpcompat

WordPress Plugin: PHP Compatibility Checker
https://wordpress.org/plugins/php-compatibility-checker/
121 stars 38 forks source link

False positive on "WP OAuth Server - Full" when tested against 7.0 #114

Open picasso opened 7 years ago

picasso commented 7 years ago
101 | ERROR | Global variable '$HTTP_RAW_POST_DATA' is deprecated since PHP 5.6 and removed since PHP 7.0 - use php://input instead.
104 | ERROR | Global variable '$HTTP_RAW_POST_DATA' is deprecated since PHP 5.6 and removed since PHP 7.0 - use php://input instead.
109 | ERROR | Global variable '$HTTP_RAW_POST_DATA' is deprecated since PHP 5.6 and removed since PHP 7.0 - use php://input instead.
112 | ERROR | Global variable '$HTTP_RAW_POST_DATA' is deprecated since PHP 5.6 and removed since PHP 7.0 - use php://input instead.

But looking at the lines 101 and 104 you see the following:

if ( ! isset( $HTTP_RAW_POST_DATA ) ) {
    return fopen( 'php://input', 'rb' );
} else {
    return $HTTP_RAW_POST_DATA;
}

And the same for lines 109 and 112:

if ( null === $this->content ) {
    if ( ! isset( $HTTP_RAW_POST_DATA ) ) {
        $this->content = file_get_contents( 'php://input' );
    } else {
        $this->content = $HTTP_RAW_POST_DATA;
    }
}
grappler commented 7 years ago

@picasso Have tried testing the code in reverse?

if ( isset( $HTTP_RAW_POST_DATA ) ) {
    return $HTTP_RAW_POST_DATA;
} else {
    return fopen( 'php://input', 'rb' );
}

As the plugin just uses the PHPCompatibility library it is best to report the false positive there: https://github.com/wimg/PHPCompatibility

jrfnl commented 7 years ago

This is actually not a false positive as the variable is found in the code, even though used correctly. All the same, there is an issue open about the principle of these kind of warnings here: https://github.com/wimg/PHPCompatibility/issues/301