Bug #78976 [Opn->Ver]: fputcsv and fwrite behavior changed from previous version on failure
| From: | cmb@php.net | Date: | Tue, 17 Dec 2019 16:41:56 +0000 |
| Subject: | Bug #78976 [Opn->Ver]: fputcsv and fwrite behavior changed from previous version on failure | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-224357@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=78976&edit=1
ID: 78976
Updated by: cmb@php.net
Reported by: nyamsprod at gmail dot com
Summary: fputcsv and fwrite behavior changed from previous
version on failure
-Status: Open
+Status: Verified
Type: Bug
Package: SPL related
PHP Version: 7.4.0
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
> Seems this BC is documented [â¦]
Indeed[1].
> but the fact that I get -1 instead of false when using
> SplFileObject::fputcsv is the real bug.
Yes. Thanks for reporting!
[1] <https://www.php.net/manual/en/migration74.incompatible.php#migration74.incompatible.core.fread-fwrite>
Previous Comments:
------------------------------------------------------------------------
[2019-12-17 12:36:33] nyamsprod at gmail dot com
Seems this BC is documented but the fact that I get -1 instead of false when using
SplFileObject::fputcsv is the real bug.
------------------------------------------------------------------------
[2019-12-17 07:39:16] nyamsprod at gmail dot com
Description:
------------
The behavior of fwrite/fputcsv and SplFileObject::fwrite and SplFileObject::fputcsv have changed in
PHP7.4 when used with a non writable stream.
see https://3v4l.org/ifpaa
Reading the changelog I fail to see where this is mention so is it the now expected behaviour from
PHP7.4+ or is it a bug ?
Test script:
---------------
<?php
$spl = new SplFileObject('php://temp', 'r');
$fh = fopen('php://temp', 'r');
var_export([
'SplFileObject::fputcsv result on failure' => $spl->fputcsv(['foo',
'bar']),
'SplFileObject::fwrite result on failure' => $spl->fwrite('foo'),
'fputcsv result on failure' => fputcsv($fh, ['foo', 'bar']),
'fwrite result on failure' => fwrite($fh, 'foo'),
]);
Expected result:
----------------
array (
'SplFileObject::fputcsv result on failure' => 0,
'SplFileObject::fwrite result on failure' => 0,
'fputcsv result on failure' => 0,
'fwrite result on failure' => 0,
)
Actual result:
--------------
array (
'SplFileObject::fputcsv result on failure' => -1,
'SplFileObject::fwrite result on failure' => false,
'fputcsv result on failure' => false,
'fwrite result on failure' => false,
)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=78976&edit=1