|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2020-07-28 12:08 UTC] chokolatrix at gmail dot com
[2020-07-30 12:56 UTC] cmb@php.net
[2021-12-07 17:01 UTC] cmb@php.net
-Assigned To:
+Assigned To: cmb
[2021-12-09 17:54 UTC] cmb@php.net
-Summary: fopen() read-only streams in write mode doesn't fail
+Summary: Console-less environments do not prevent std streams
to be opened
[2021-12-09 17:54 UTC] cmb@php.net
[2021-12-14 11:45 UTC] cmb@php.net
-Type: Bug
+Type: Documentation Problem
-Assigned To: cmb
+Assigned To:
[2021-12-14 11:45 UTC] cmb@php.net
[2022-10-06 10:49 UTC] bukka@php.net
-Package: Filesystem function related
+Package: CGI/CLI related
[2022-10-06 10:49 UTC] bukka@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 06:00:01 2025 UTC |
Description: ------------ PHP's fopen() should fail to: - open read-only streams in write mode (STDIO in 'w' or other write modes) - open write-only streams in read mode (STDOUT, STDERR etc. in 'r' or other read modes) This was noticed because of Laravel's logging to stderr failing under Apache/2.4.29 (Win64) mod_fcgid/2.3.9 and PHP 7.4.8 x64 NTS. There is possibly a bug with Apache and FastCGI exposing STDERR as non-writable (normally writes STDERR to the error log), but Laravel logging code checks fopen() result being a stream before writing to it. Test script: --------------- <?php # c:\my-site\test.php error_reporting(E_ALL); ini_set('display_errors','On'); $fp = fopen('php://stdin', 'w'); var_dump($fp); $fp = fopen('php://stderr', 'r'); var_dump($fp); if ($fp) { // this then fails on Apache + FastCGI - might be an Apache + FCGI bug causing stderr not to be writable fwrite($fp, "test"); } Expected result: ---------------- bool(false) bool(false) Actual result: -------------- Notice: fwrite(): write of 4 bytes failed with errno=9 Bad file descriptor in test.php on line 7 resource(3) of type (stream) resource(4) of type (stream)