#23406 [Ana]: \r\n not functioning the same from 4.3.1 and prior
| From: | wez@php.net | Date: | Thu, 01 May 2003 14:24:07 +0000 |
| Subject: | #23406 [Ana]: \r\n not functioning the same from 4.3.1 and prior | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-38882@lists.php.net to get a copy of this message | ||
ID: 23406
Updated by: wez@php.net
Reported By: gfraley5 at earthlink dot net
Status: Analyzed
Bug Type: Filesystem function related
Operating System: Win98SE,WinXP,Win2K
PHP Version: 4.3.2RC2
Assigned To: wez
New Comment:
The reason for the change was primarily to avoid crippling limitations
for the number of opened files under Solaris, but has other benefits
for the streams API.
My opinion of the backwards compatibility issue here is that it should
be a non-issue; the fopen() docs have warned about binary mode for a
very long time. However, I think we will wait and see if we get any
more feedback on this issue before making a firm decision.
Previous Comments:
------------------------------------------------------------------------
[2003-05-01 09:18:37] gfraley5 at earthlink dot net
Thanks! I have submitted this in the past and it was rebuffed and
marked as bogus. I don't think it should be marked as bogus because it
is a definite backward compatability issue that will render files
useless (as it does with hundreds of my users that use legacy 'w'
instead of 'wb') if written to without the 'B' attribute. If anything,
it could/should be marked as an 'enhancement' or something as you have
changed the behavior whether intentionally or not. Was there a
specific reason why you wnet to the lower level call open()? If
nothing in particular, then maybe you leave 4.3.2 as is and prepare the
public and developers for the change in a future release. Just a
thought.
------------------------------------------------------------------------
[2003-05-01 09:11:49] wez@php.net
The Apache SAPI leaves the _fmode variable as-is, whereas the CLI, CGI
and Embed SAPIs all force it to binary mode.
What this means is that for the latter three,
fopen($file, "r") is forced to fopen($file, "rb") internally by the MS
libc.
Technically speaking this behaviour is a bit naughty, as it prevents
opening files in text-mode when using CLI and CGI, and Embed interferes
with the hosting application's binary settings (this is the main reason
we don't set it in Apache).
I can't find any logical reason for the apparent change in behaviour
under Apache, except for the fact that we are now using the lower level
file descriptors returned by _open() rather than calling the slightly
higher level fopen() to get at the files. Why this makes a difference,
I can't tell (it just doesn't make sense).
However, all of this aside, the behaviour you are currently
experiencing under Apache is the technically correct behaviour that you
should expect when opening a file in text mode.
The correct fix for your problem is to open the file in binary mode, as
is suggested in the PHP manual for the fopen() function, and in
numerous places throughout the manual when talking about binary
safety.
I'm tempted to mark this report as bogus (because it is the expected
behaviour), but want to discuss the implications of this with some of
the other developers first, because of potential backwards
compatibility issues.
------------------------------------------------------------------------
[2003-04-30 13:58:38] gfraley5 at earthlink dot net
Apache
------------------------------------------------------------------------
[2003-04-30 13:18:02] wez@php.net
Which SAPI are you using?
CGI/FastCGI, Apache or IIS?
------------------------------------------------------------------------
[2003-04-30 12:06:54] gfraley5 at earthlink dot net
From 4.2.3
Wrote: 76 bytes; filesize is now 80 ==== using readfile ===== msgid
1049987091 1050930128 ==== readfile read 80 bytes ==== ==== using fopen
'r' === msgid 1049987091 1050930128 ==== using fopen 'rb' === msgid
1049987091 1050930128 ==== done ===
From 4.3.2
Wrote: 76 bytes; filesize is now 77 ==== using readfile ===== msgid
1049987091 1050930128 ==== readfile read 77 bytes ==== ==== using fopen
'r' === msgid 1049987091 1050930128 ==== using fopen 'rb' === msgid
1049987091 1050930128 ==== done ===
------------------------------------------------------------------------
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
http://bugs.php.net/23406
--
Edit this bug report at http://bugs.php.net/?id=23406&edit=1