php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #72954 file_get_contents: It does not return false at the time of time-out
Submitted: 2016-08-28 03:14 UTC Modified: 2016-09-11 04:22 UTC
From: ne20utri312no at yahoo dot co dot jp Assigned:
Status: No Feedback Package: HTTP related
PHP Version: 7.0.10 OS: Windows
Private report: No CVE-ID: None
 [2016-08-28 03:14 UTC] ne20utri312no at yahoo dot co dot jp
Description:
------------
file_get_contents
It does not return false at the time of time-out

php 7.0.10 (php 5.6 does not have this bug)

open two shell.
(1)
php -S localhost:8080
(2)
php 2.php

Execution result: 1.0 sec , string(0) ""
FAILURE
 Expected result:   1 sec , bool(false)


Test script:
---------------
<?php
// php -S localhost:8080
// php 2.php

ini_set('display_errors', 0);
if (php_sapi_name() == 'cli')
{
	$timeout = 1;
	ini_set('default_socket_timeout', $timeout);
	$st = microtime(TRUE);
	$res = file_get_contents('http://localhost:8080/'. basename(__FILE__));
	$time = microtime(TRUE) - $st;
	ob_start(); var_dump($res); $s = trim(ob_get_contents()); ob_end_clean();
	printf("Execution result: %0.1f sec , %s\n", $time, $s);
	$success = ($res ===FALSE && round($time)<=$timeout);
	echo ($success ? 'Success' : 'FAILURE'). "\n";
	printf(" Expected result: %3d sec , bool(false)\n", $timeout);
}
else
{
	echo "Hello";
	flush();
	sleep(1);
	echo ' world';
}

Expected result:
----------------
bool(false)

Actual result:
--------------
string(0) ""

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-08-28 18:43 UTC] ab@php.net
-Status: Open +Status: Feedback
 [2016-08-28 18:43 UTC] ab@php.net
Thanks for the report. With both 5.6 and 7.0 i get with the test script

Execution result: 1.0 sec , string(5) "Hello"
FAILURE
 Expected result:   1 sec , bool(false)

This is correct, as "hello" is flushed before sleep. Please provide additional info on how to reproduce the current behavior you describe. Also, please be sure, there's no any other process listening on the same port.

Thanks.
 [2016-09-11 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 05:01:30 2024 UTC