zendframework / zend-feed

Feed component from Zend Framework
BSD 3-Clause "New" or "Revised" License
166 stars 42 forks source link

$GLOBALS['HTTP_RAW_POST_DATA'] is deprecated in PHP 5.6, from AbstractCallback.php #10

Closed RobLoach closed 6 years ago

RobLoach commented 9 years ago

The AbstractCallback class makes use of $GLOBALS['HTTP_RAW_POST_DATA'], which is deprecated in PHP 5.6.

    /**
     * Return the raw body of the request
     *
     * @return string|false Raw body, or false if not present
     */
    protected function _getRawBody()
    {
        $body = file_get_contents('php://input');
        if (strlen(trim($body)) == 0 && isset($GLOBALS['HTTP_RAW_POST_DATA'])) {
            $body = $GLOBALS['HTTP_RAW_POST_DATA'];
        }
        if (strlen(trim($body)) > 0) {
            return $body;
        }
        return false;
    }

I suggest either:

  1. Removing those three lines entirely, as it will not be automatically filled in the future
  2. Checking for PHP < 5.6 beforehand
Maks3w commented 9 years ago

As far as I see there is no need for check about the php version because the isset method is safe in that future.

May just add a comment advising about the required php version for locate and remove dead code in the future.

kabirbaidhya commented 8 years ago

Yes, due to this I'm getting deprecated messages time and again in my application and had to make changes in the php.ini to hide it.

PHP Deprecated:  Automatically populating $HTTP_RAW_POST_DATA is deprecated and will be removed in a future version. To avoid this warning set 'always_populate_raw_post_data' to '-1' in php.ini and use the php://input stream instead. in Unknown on line 0
weierophinney commented 8 years ago

@kabirbaidhya and/or @RobLoach — as this is a relatively easy fix, would one of you be willing to provide a pull request?

kabirbaidhya commented 8 years ago

:+1: