php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #78575 copy() always report an error with a custom stream wrapper
Submitted: 2019-09-20 13:02 UTC Modified: 2019-10-30 10:32 UTC
Votes:5
Avg. Score:4.0 ± 0.6
Reproduced:5 of 5 (100.0%)
Same Version:5 (100.0%)
Same OS:4 (80.0%)
From: thomas dot gerbet at enalean dot com Assigned: nikic (profile)
Status: Closed Package: Streams related
PHP Version: 7.4.0RC2 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
45 - 5 = ?
Subscribe to this entry?

 
 [2019-09-20 13:02 UTC] thomas dot gerbet at enalean dot com
Description:
------------
Issue found while using the vfsStream library [0]. copy() always return false even if the data are actually copied.


This behaviour change seems to be present since https://github.com/php/php-src/commit/11f3e24190fa45689c8ccaeea54a28db6752092e


[0] https://github.com/bovigo/vfsStream

Test script:
---------------
<?php

// See https://github.com/LeSuisse/php74-rc2-streamwrapper-bug

require_once __DIR__ . '/vendor/autoload.php';

$fs = org\bovigo\vfs\vfsStream::setup();
$source_path = $fs->url() . '/f1';
file_put_contents($source_path, 'A');
$destination_path = $fs->url() . '/f2';
var_dump(copy($source_path, $destination_path));
var_dump(file_get_contents($destination_path));

Expected result:
----------------
bool(true)
string(1) "A"

Actual result:
--------------
bool(false)
string(1) "A"

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-10-30 10:25 UTC] nikic@php.net
copy() reports an error because a stream_read() call reported an error by returning false. Possibly something in the implementation needs to be adjusted to return "" instead of false on EOF?
 [2019-10-30 10:28 UTC] nikic@php.net
Looks like that's indeed the case, and the issue has been recently fixed: https://github.com/bovigo/vfsStream/pull/204

Possibly we need to mention this potential issue in UPGRADING.
 [2019-10-30 10:32 UTC] nikic@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: nikic
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sat Sep 26 09:01:24 2020 UTC