`is_readable()` and `is_writable()` return false negative on Win32's network-mapped drives
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- C
- Star
- 40.4k
- Fork
- 8.2k
- Merge trung bình
- 2 ngày 15 giờ
- Pull request đã merge (30 ngày)
- 103
Mô tả
Description
Hi there, good morning PHP team!
I'm working with PHP-CLI on Windows, and part of my project checks if a file path is readable and/or writable. This works as expected if the file in in the local disk, such as C:\.
However, Windows has a feature named network-mapped drives where you can "mount" a shared folder from another host to appear as a local disk, for example the SMB network share \\computername\foo\bar can be "mounted" to Z:\. In this case, calls to file_get_contents() and file_put_contents() will actually succeed, but the corresponding calls to is_readable() and is_writable() will return false.
Consider the following code:
$my_file = "Z:\\Users\\David\\File.txt";
var_dump(
is_readable($my_file),
is_writable($my_file),
file_get_contents($my_file));
This results in this output:
bool(false)
bool(false)
string(34) "I am the content of the `my_file`!"
But I expect the following output:
bool(true)
bool(true)
string(34) "I am the content of the `my_file`!"
I was curious about this behavior, so I read the documentation for is_readable(), and the only piece of useful info I found is a very old user notes contribution that says:
..."is_readable() checks whether you can do file_get_contents() or similar calls, no more, no less."
~ jo at durchholz dot org
This doesn't seem right to me, because as you can see, the file_get_contents() is clearly succeeding while the is_readable() call is failing.
Please note that the PHP-CLI is running through command line with my own user account, not as some service where it wouldn't have access to the network-mapped drive.
So, I'm curious why this happens. Can you please link me to the relevant part of the source tree that implements is_readable() and is_writable()? I'm curious why this issue exists.
Thanks!
PHP Version
PHP 8.1.13
Operating System
Windows 11 Enterprise 22H2
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu bằng cách xác định các phần triển khai của is_readable() và is_writable() trong cây mã nguồn, sau đó tái hiện hành vi được báo cáo trên Windows 11 bằng ví dụ PHP 8.1.13 được cung cấp và một ổ đĩa được ánh xạ qua mạng. So sánh các kiểm tra đó với file_get_contents() và file_put_contents(); công việc được hoàn tất khi đã xác định nguyên nhân và ghi lại hoặc khắc phục sự khác biệt.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- c, php
- Lĩnh vực
- operating-systems
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Cần làm rõ
- Mức phù hợp với người mới
- 35/100