OK, I'm now seeing a pass rate that more or less matches the same tests run
by the PHP 5 test script and PHP 5.3 binary.
FILE_BINARY
is needed in two of seven calls to file_put_contents()
. Get it
wrong (either way) and you get a random warning or notice. It's completely
non-portable too - it will only be accepted under PHP 6.
There is far too much of this kind of thing. Can we please consider adding
dummies into at least 5.3.0 and possibly even the 5_2 branch for:
is_binary()
is_unicode()
file_put_contents(FILE_BINARY)
and any other major 'gotchas' that people can think of that will make it
impossible to write future-compatible PHP 5 code?
Thanks,
- Steph
----- Original Message -----
From: "Steph Fox" steph@phparch.com
To: "internals" internals@lists.php.net
Sent: Thursday, June 12, 2008 3:32 AM
Subject: [PHP-DEV] HEAD tests broken under Windows
Hi all,
I'm hopeful that run-tests.php will now work as advertised under CVS HEAD
in most places. However it's still not right under Windows, and I finally
tracked that down to the fact thatfile_put_contents()
in PHP 6 will
insist on creating a file with DOS line endings. The test files are
created from .phpt --FILE-- sections usingfile_put_contents()
, so there
are a vast number of fails under doze due to an extra character in output
strings there.There's a closed PHP bug on this which was raised by Zoe over a year
ago, see http://bugs.php.net/bug.php?id=41609. For some obscure reason it
was seen as a documentation problem at the time. This is an extreme change
in behaviour, not a documentation problem, and needs proper analysis.Could someone please look into it?
Thanks,
- Steph
Hi,
There is far too much of this kind of thing. Can we please consider adding
dummies into at least 5.3.0 and possibly even the 5_2 branch for:is_binary()
is_unicode()
These can be easily emulated using PHP like
if (!function_exists("is_binary")) {
function is_binary($s) { return is_string($s); }
}
file_put_contents(FILE_BINARY)
Would a const FILE_BINARY
= 0; be enough or would that break the
function in some way (didn't check it)
and any other major 'gotchas' that people can think of that will make it
impossible to write future-compatible PHP 5 code?
as long as such an emulation is possible I'd prefer putting them in a
compatibility layer (like PEAR PHP_Compat) using PHP instead of putting
"useless" (mind the quotes ...) functions into PHP.
Stuff like the b prefix or (binary) casts are different as they can't be
emulated using userland stuff.
johannes
Thanks,
- Steph
----- Original Message -----
From: "Steph Fox" steph@phparch.com
To: "internals" internals@lists.php.net
Sent: Thursday, June 12, 2008 3:32 AM
Subject: [PHP-DEV] HEAD tests broken under WindowsHi all,
I'm hopeful that run-tests.php will now work as advertised under CVS HEAD
in most places. However it's still not right under Windows, and I finally
tracked that down to the fact thatfile_put_contents()
in PHP 6 will
insist on creating a file with DOS line endings. The test files are
created from .phpt --FILE-- sections usingfile_put_contents()
, so there
are a vast number of fails under doze due to an extra character in output
strings there.There's a closed PHP bug on this which was raised by Zoe over a year
ago, see http://bugs.php.net/bug.php?id=41609. For some obscure reason it
was seen as a documentation problem at the time. This is an extreme change
in behaviour, not a documentation problem, and needs proper analysis.Could someone please look into it?
Thanks,
- Steph
Hi Johannes,
These can be easily emulated using PHP like
if (!function_exists("is_binary")) {
function is_binary($s) { return is_string($s); }
}file_put_contents(FILE_BINARY)
Obviously... I was just thinking about the amount of stuff that would need
to be added to that compatibility layer, and how it might affect
portability. Not everyone uses PEAR and here we're more or less forcing a
dependency on it, with the option being to knit one's own. Also, since many
are only now moving from PHP 4, it seems a bit harsh to tell them they're
going to have to change their code all over again in a couple of years' time
for PHP 6 when they could be doing it all at one hit.
Would a const
FILE_BINARY
= 0; be enough or would that break the
function in some way (didn't check it)
#define PHP_FILE_TEXT 32
#define PHP_FILE_BINARY 64
And again, yes you can do it in userland code (FILE_TEXT, FILE_BINARY) and
it harms nothing.
as long as such an emulation is possible I'd prefer putting them in a
compatibility layer (like PEAR PHP_Compat) using PHP instead of putting
"useless" (mind the quotes ...) functions into PHP.
We'll have to agree to disagree over this...
- Steph