Skip to content

copy() target is blank in PHP 8.2.0-rc3 #9653

Closed

Description

@pesselbach

Description

The following code:

<?php
copy("test.txt", "testcopy.txt");

Resulted in this output:
testcopy.txt is an empty 0 bytes file.

But I expected this output instead:
testcopy.txt is a copy of test.txt

The following workaround is working:

<?php
file_put_contents("testcopy.txt", file_get_contents("test.txt"));

This problem exists at least since PHP 8.2.0-rc1. Production versions such as PHP 8.1.11 are working as expected. I am using Debian 10 with the packages provided by https://deb.sury.org running in a VirtualBox machine.

PHP Version

PHP 8.2.0-rc3

Operating System

Debian 10

Activity

  1. devnexen commented on Oct 1, 2022

    @devnexen
    Member

    I built the same environment but was unable to reproduce the issue, always successful copies. Is it possible to get a bit more context or a minimum reproducer ?

  2. pesselbach commented on Oct 2, 2022

    @pesselbach
    Author

    I did further testing. This only happens if the target directory is in a VirtualBox shared folder.

  3. devnexen commented on Oct 2, 2022

    @devnexen
    Member

    Thanks. It might have to do with the copy optimisation introduced couple of months ago and we re running a kernel version pre-5.3. Indeed, when I boot with the other buster kernel image 5.10, the copy seems to work.

  4. self-assigned this
    on Oct 2, 2022
  5. devnexen commented on Oct 2, 2022

    @devnexen
    Member

    @pesselbach you can try the aforementioned PR branch, the copy worked again on the base 4.19 kernel image with this change.

  6. bukka commented on Oct 6, 2022

    @bukka
    Member

    @devnexen Added few comments on one of the commits - not sure if it's visible. Maybe just do a PR. It seems reasonable to me to do this check if it doesn't work well before 5.3 kernel.

  7. devnexen commented on Oct 6, 2022

    @devnexen
    Member

    PR is there ;-) but yes I did see your comments thx

  8. added a commit that references this issue on Feb 1, 2024
    c15fe51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions