php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #60775 file_get_contents does not return all content
Submitted: 2012-01-17 02:41 UTC Modified: 2012-01-23 08:15 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: tech163 at fusionswift dot com Assigned:
Status: Not a bug Package: Streams related
PHP Version: 5.3.9 OS: CentOS 6.2
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: tech163 at fusionswift dot com
New email:
PHP Version: OS:

 

 [2012-01-17 02:41 UTC] tech163 at fusionswift dot com
Description:
------------
This error began appearing a few days ago after I ran yum update, and recompiled 
PHP, using 

'./configure'  '--prefix=/home/arch120113' '--with-config-file-
path=/home/arch120112/php' '--with-mysqli=mysqlnd' '--with-mysql=mysqlnd' '--with-
pdo-mysql=mysqlnd' '--with-mysql-sock=/var/lib/mysql/mysql.sock' '--enable-bcmath' 
'--enable-calendar' '--enable-exif' '--enable-ftp' '--enable-magic-quotes' '--
enable-mbstring' '--enable-sockets' '--with-bz2' '--with-curl' '--with-gd' '--
enable-gd-native-ttf' '--with-jpeg-dir=/opt' '--with-png-dir=/opt' '--with-
gettext' '--with-imap' '--with-imap-ssl' '--with-kerberos' '--with-mcrypt' '--
with-openssl' '--with-zlib' '--enable-zip' '--enable-fpm' '--with-freetype-
dir=/usr/include/freetype2/'

Now, when I use file_get_contents() on a large file (300KB), not the entire thing 
appears.

Test script:
---------------
https://www.cheatswhiz.com/info.php

<?php

<?php
$expires_offset = 31536000;


header('Content-Type: application/x-javascript; charset=UTF-8');
header('Vary: Accept-Encoding'); // Handle proxies
header('Expires: ' . gmdate( "D, d M Y H:i:s", time() + $expires_offset ) . ' GMT');
header("Cache-Control: public, max-age=$expires_offset");

echo file_get_contents('wp-includes/js/tinymce/wp-tinymce.js');

?>

File it's reading from is https://www.cheatswhiz.com/wp-includes/js/tinymce/wp-tinymce.js

Expected result:
----------------
The entire content of the file is read. 

Actual result:
--------------
Only part of the content is read 

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-01-17 13:00 UTC] mike@php.net
-Status: Open +Status: Feedback
 [2012-01-17 13:00 UTC] mike@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc. If the script requires a 
database to demonstrate the issue, please make sure it creates 
all necessary tables, stored procedures etc.

Please avoid embedding huge scripts into the report.


 [2012-01-17 13:02 UTC] tech163 at fusionswift dot com
<?php

<?php
$expires_offset = 31536000;


header('Content-Type: application/x-javascript; charset=UTF-8');
header('Vary: Accept-Encoding'); // Handle proxies
header('Expires: ' . gmdate( "D, d M Y H:i:s", time() + $expires_offset ) . ' 
GMT');
header("Cache-Control: public, max-age=$expires_offset");

echo file_get_contents('wp-includes/js/tinymce/wp-tinymce.js');

echo 'test';
?>

where the file, wp-includes/js/tinymce/wp-tinymce.js, contains 
https://www.cheatswhiz.com/wp-includes/js/tinymce/wp-tinymce.js. When that code 
is excuted, only portions of https://www.cheatswhiz.com/wp-
includes/js/tinymce/wp-tinymce.js is read, Also, the echo 'test'; after the 
file_get_contents is not executed.
 [2012-01-17 13:02 UTC] tech163 at fusionswift dot com
-Status: Feedback +Status: Open
 [2012-01-17 16:49 UTC] mike@php.net
Look, how should I reproduce when this script only works on your server.
Please provide a self-contained reproduce case.  Eventually check your server 
config, too.
 [2012-01-17 16:49 UTC] mike@php.net
-Status: Open +Status: Feedback
 [2012-01-18 03:43 UTC] tech163 at fusionswift dot com
Oops. Seemed to be a nginx proxy issue.
 [2012-01-18 03:43 UTC] tech163 at fusionswift dot com
-Status: Feedback +Status: Closed
 [2012-01-23 08:15 UTC] cataphract@php.net
-Status: Closed +Status: Bogus
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 16:01:28 2024 UTC