Doc #78885 [Com]: hash_file now shows a notice for directories and returns false
[email protected] ("alisawefguxbpn53 at gmail dot com") Sat, 28 Jan 2023 09:25:04 +0000
| Newsgroups | php.doc.bugs |
|---|---|
| Message-ID | <[email protected]> |
Edit report at https://bugs.php.net/bug.php?id=78885&edit=1
ID: 78885
Comment by: alisawefguxbpn53 at gmail dot com
Reported by: php-bugs at xpaw dot me
Summary: hash_file now shows a notice for directories and
returns false
Status: Open
Type: Documentation Problem
Package: Filesystem function related
Operating System: Linux
PHP Version: 7.4.0
Block user comment: N
Private report: N
New Comment:
That was so amazing
Previous Comments:
------------------------------------------------------------------------
[2020-11-03 18:09:41] [email protected]
Changing to doc problem for now (IIRC, there is at least one
duplicate of this ticket).
------------------------------------------------------------------------
[2019-12-04 09:57:14] [email protected]
This is intentional. PR #4474 is also still relevant, because it is a change specific to includes (not normal file reads).
UPGRADING currently only mentions this change for fread() and fwrite() in particular, but of course it also affects many, many other filesystem functions that read/write internally. I don't think we want to exhaustively list everything that might be affected.
------------------------------------------------------------------------
[2019-11-29 14:05:56] [email protected]
Well, the behavioral change has been introduced with commit
1cbcf0f[1]; not sure whether this particular behavior has been
anticipated. If so, PR #4474[2] appears to be superfluous now.
[1] <http://git.php.net/?p=php-src.git;a=commit;h=1cbcf0f4f1e9a14b3fc76f6d3e53b567a9464fd4>
[2] <https://github.com/php/php-src/pull/4474>
------------------------------------------------------------------------
[2019-11-29 12:34:44] [email protected]
This is not particularly related to hash_file(), but also affects
other filesystem functions, see <https://3v4l.org/5XQB3>. IIRC,
that was a very deliberate change/fix.
------------------------------------------------------------------------
[2019-11-29 10:57:37] php-bugs at xpaw dot me
Description:
------------
See https://3v4l.org/58RgW
Until 7.4.0beta1, it returned string(32) "d41d8cd98f00b204e9800998ecf8427e" and since 7.4.0beta2 it displays a notice.
Notice: hash_file(): read of 8192 bytes failed with errno=21 Is a directory in /in/58RgW on line 3
On Windows there is no notice, and it only returns false. I'm only creating this issue as I don't see anything in upgrading notes, deprecated features or the changelog about it.
Test script:
---------------
<?php
var_dump( hash_file( 'md5', '/etc/' ) );
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=78885&edit=1