Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
pesselbach opened this issue Oct 1, 2022 · 6 comments
Closed

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

pesselbach opened this issue Oct 1, 2022 · 6 comments

Comments

@pesselbach
Copy link

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

@devnexen
Copy link
Member

devnexen commented Oct 1, 2022

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 ?

@pesselbach
Copy link
Author

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

@devnexen
Copy link
Member

devnexen commented Oct 2, 2022

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.

@devnexen devnexen self-assigned this Oct 2, 2022
devnexen added a commit to devnexen/php-src that referenced this issue Oct 2, 2022
…lder kernels.

As mentioned in its manpage, it had been reworked in the 5.3 line to support cross filesystem interactions.
@devnexen
Copy link
Member

devnexen commented Oct 2, 2022

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

devnexen added a commit to devnexen/php-src that referenced this issue Oct 2, 2022
…lder kernels.

As mentioned in its manpage, it had been reworked in the 5.3 line to support cross filesystem interactions.
@bukka
Copy link
Member

bukka commented Oct 6, 2022

@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.

@devnexen
Copy link
Member

devnexen commented Oct 6, 2022

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

devnexen added a commit to devnexen/php-src that referenced this issue Oct 6, 2022
…lder kernels.

As mentioned in its manpage, it had been reworked in the 5.3 line to support cross filesystem interactions.
devnexen added a commit to devnexen/php-src that referenced this issue Oct 6, 2022
…lder kernels.

As mentioned in its manpage, it had been reworked in the 5.3 line to support cross filesystem interactions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants