Doc #69290 [Ver->Csd]: Invalid modes do not trigger errors
| From: | git@php.net | Date: | Thu, 02 Dec 2021 17:07:07 +0000 |
| Subject: | Doc #69290 [Ver->Csd]: Invalid modes do not trigger errors | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-19352@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=69290&edit=1
ID: 69290
Updated by: git@php.net
Reported by: roborg at gmail dot com
Summary: Invalid modes do not trigger errors
-Status: Verified
+Status: Closed
Type: Documentation Problem
Package: Program Execution
Operating System: Windows
PHP Version: 5.5.23
Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
Automatic comment on behalf of cmb69
Revision: https://github.com/php/doc-en/commit/c1f8c2ea33c70f59557175e1a43af7153b1df565
Log: Fix #69290: Invalid modes do not trigger errors
Previous Comments:
------------------------------------------------------------------------
[2021-12-02 17:01:39] cmb@php.net
> I understand BC is a concern, but the only scripts affected by
> this are ones that aren't working anyway - they're just failing
> silently, which in my opinion is much worse than generating an
> error of some level (even just a notice).
Not quite. Anthing else than 'w' is treated like 'r', like
@laruence already stated above.
Anyhow, no progress after more than six years makes me think it's
better to document the behavior than to wait for someone to
implement this feature request.
------------------------------------------------------------------------
[2015-03-28 14:54:31] roborg at gmail dot com
Hi
This isn't really related to #51800 - that's just how I found out that my script
wasn't working.
I understand BC is a concern, but the only scripts affected by this are ones that aren't
working anyway - they're just failing silently, which in my opinion is much worse than
generating an error of some level (even just a notice).
If you pass in an invalid value for the first parameter e.g. change 'pipe' to
'foo' then you get an error - I can't see a reason that the mode parameter
shouldn't be checked as well.
I guess if silently failing is what was intended then this is more of a feature request than a bug
report so I'll update the type.
------------------------------------------------------------------------
[2015-03-28 11:39:54] ab@php.net
@roborg thanks for the report.
With the script hanging, I guess you're hitting the bug #51800 in 5.3 which was fixed in 5.5+
around last autumn. Pipe buffer on windows is way too small and can cause race conditions. Please
check, if it's so - we can close this.
Besides that, something standing in the comments is not the documentation, so it makes absolutely no
sense to claim it a bug if it doesn't work.
Thanks.
------------------------------------------------------------------------
[2015-03-28 10:38:30] roborg at gmail dot com
Status
------------------------------------------------------------------------
[2015-03-28 10:37:36] roborg at gmail dot com
I've tested the script below with these results (sorry, I can't run these on the same OS):
PHP: 5.3.5
OS: Win XP
Mode: w
Result: Script hangs
PHP: 5.3.5
OS: Win XP
Mode: a
Result: Empty string
PHP: 5.5.13
OS: Win 7
Mode: w
Result: string 'x.......'
PHP: 5.5.13
OS: Win 7
Mode: a
Result: Empty string
So the behavior has changed somewhat between 5.3 and 5.5, but not in the way I thought...
It looks like the "a" mode never actually worked (as the output was empty), but just
tricked PHP/Windows into not hanging.
I still think failing silently is a really bad thing though.
<?php
$descriptors = array(
array('pipe', 'r'),
array('pipe', 'w'),
array('pipe', 'w'), // This one changes between 'a' and 'w'
);
$process = proc_open('c:\php\php.exe -r "$f = fopen(\'php://stderr\',
\'w+\');fwrite($f, str_repeat(\'x\' . chr(10), 2048));', $descriptors,
$pipes);
var_dump(stream_get_contents($pipes[1]));
var_dump(stream_get_contents($pipes[2]));
proc_close($process);
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=69290
--
Edit this bug report at https://bugs.php.net/bug.php?id=69290&edit=1