|  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
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.


Add a Patch

Pull Requests

Add a Pull Request


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.
 [2017-05-03 05:18 UTC]
-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-2021 The PHP Group
All rights reserved.
Last updated: Sat Jul 31 13:01:25 2021 UTC