Bug #78976 [Com]: fputcsv and fwrite behavior changed from previous version on failure
| From: | nyamsprod at gmail dot com | Date: | Tue, 17 Dec 2019 12:36:33 +0000 |
| Subject: | Bug #78976 [Com]: fputcsv and fwrite behavior changed from previous version on failure | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-224351@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
Comment by: nyamsprod at gmail dot com
Reported by: nyamsprod at gmail dot com
Summary: fputcsv and fwrite behavior changed from previous
version on failure
Status: Open
Type: Bug
Package: SPL related
PHP Version: 7.4.0
Block user comment: N
Private report: N
New Comment:
Seems this BC is documented but the fact that I get -1 instead of false when using
SplFileObject::fputcsv is the real bug.
Previous Comments:
------------------------------------------------------------------------
[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