Skip to content

[8.2] stream_copy_to_stream doesn't work anymore with resource opened in a append mode #9779

Closed
@Slamdunk

Description

@Slamdunk

Description

The following code:

<?php
file_put_contents("./source", "bar");
file_put_contents("./dest", "foo");
$sourceHandle = fopen("./source", "r");
$destHandle = fopen("./dest", "a");
stream_copy_to_stream($sourceHandle, $destHandle);
fclose($sourceHandle);
fclose($destHandle);
var_dump(file_get_contents("./dest"));

Resulted in this output:

string(3) "foo"

But I expected this output instead:

string(6) "foobar"

PHP Version

PHP 8.2.0RC3 (cli) (built: Sep 29 2022 22:31:18) (NTS)

Operating System

Ubuntu 22.04.1

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions