php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74512 file_get_contents fails on zlib compressed stream
Submitted: 2017-04-28 18:57 UTC Modified: 2017-05-03 05:42 UTC
From: wellu at wellu dot org Assigned:
Status: Not a bug Package: Filesystem function related
PHP Version: 7.0.18 OS: Ubuntu 16.04.2 LTS
Private report: No CVE-ID: None
 [2017-04-28 18:57 UTC] wellu at wellu dot org
Description:
------------
Exact PHP version: PHP 7.0.15-0ubuntu0.16.04.4 (this was not selectable in dropdown?)

I'm posting raw JSON data to a webserver that is gzipped. Server code is:

$input_data = json_decode(trim(file_get_contents("compress.zlib://php://input")), true);

which should read whatever is posted, then deflate it and then turn it in to an object.

This exact code used to work in Ubuntu 14.04 which had PHP 5.x something but now I'm getting:

ERROR - 2017-04-28 13:41:42 --> Severity: Warning  --> file_get_contents(compress.zlib://php://input): failed to open stream: operation failed /srv/www/xxx/xxx.php 51
ERROR - 2017-04-28 13:42:19 --> Severity: Warning  --> file_get_contents(): cannot represent a stream of type Input as a File Descriptor

which points to the line in the beginning of this bug report. Nothing changed in the client but upgrading from 5.x to 7.x broke this.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-05-02 10:45 UTC] wellu at wellu dot org
-Status: Open +Status: Closed
 [2017-05-02 10:45 UTC] wellu at wellu dot org
Ok, sorted this one out. Apparently in 5.6 you can't use file_get_contents anymore like in the past.

https://secure.phabricator.com/rP42566379dc3c4fd01a73067215da4a7ca18f9c17
 [2017-05-03 05:18 UTC] rasmus@php.net
-Status: Closed +Status: Not a bug
 [2017-05-03 05:42 UTC] wellu at wellu dot org
Just out of curiosity: is / was this breaking change in file_get_contents officially documented somewhere?
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Fri Dec 04 03:01:23 2020 UTC