|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2018-02-05 20:44 UTC] nikic@php.net
[2018-02-05 20:44 UTC] nikic@php.net
-Status: Open
+Status: Closed
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 08:00:01 2025 UTC |
Description: ------------ The issue: When using file_get_contents to request an http URL a magical $http_response_header variable is set in the local context. This variable (array) works as expected when accessed directly, but if we assign it to a temporary variable ($status_code_string in the example), the value is lost. Preconditions: This issue only happens when the opcache is enabled (eg. opcache.enable = 1 and opcache.enable_cli=1 for cli testing). The bug itself was discovered in php-fpm, but providing a demonstration for that is more tricky. I'm unsure of exactly how it's possible, but the issue only seems to trigger on the second run. The issue is present in PHP 7.2.1. The issue does not seem to be present in PHP 7.2.0. The issue is not present in PHP 7.1.13. Test script: --------------- <?php class debug { public static function bug() { $url = 'http://php.net'; $response = file_get_contents($url); $status_code_string = $http_response_header[0]; print('indirect ' . $status_code_string . "\n"); print('direct ' . $http_response_header[0] . "\n"); print(is_null($http_response_header[0]) . "\n"); print(is_null($status_code_string) . "\n"); } } $debug = new debug(); $debug::bug(); Expected result: ---------------- The $status_code_string variable should be equivalent to $http_response_header[0]. Neither of the variables should return true for is_null. Actual result: -------------- Only $http_response_header[0] contains the expected response. Both variables return true for is_null!