Bug #76379 [Opn->Nab]: cant touch with $atime=null
| From: | cmb@php.net | Date: | Sat, 26 May 2018 12:24:11 +0000 |
| Subject: | Bug #76379 [Opn->Nab]: cant touch with $atime=null | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-215374@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=76379&edit=1
ID: 76379
Updated by: cmb@php.net
Reported by: remco at priya dot software
Summary: cant touch with $atime=null
-Status: Open
+Status: Not a bug
Type: Bug
-Package: URL related
+Package: Filesystem function related
Operating System: PHP 7.2.5-1+ubuntu14.04.1+deb.su
PHP Version: 7.2.6
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
There is no way to *skip* optional function parameters in PHP. A
respective RFC[1] had been declined. Passing NULL to an optional
parameter does *not* necessarily use its default, but NULL, which
in this case is converted to 0. So it is up to the userland
developer to pass appropriate default values, e.g. in this case:
function my_touch($url, $time, $atime=null) {
return touch($url, $time, $atime ?? $time);
}
[1] <https://wiki.php.net/rfc/skipparams>
Previous Comments:
------------------------------------------------------------------------
[2018-05-25 20:50:10] remco at priya dot software
Description:
------------
see the test script
( ! ) Warning: touch(): Utime failed: Operation not permitted in
/mnt/c/Library/Server/Vendor/Priya/Module/File/Class/File.class.php on line 40
Test script:
---------------
//works
public static function touch($url='', $time=null, $atime=null){
if($atime === null){
return touch($url, $time);
} else {
return touch($url, $time, $atime);
}
}
// doesnt work:
public static function touch($url='', $time=null, $atime=null){
return touch($url, $time, $atime);
}
//$url =
'/mnt/c/Library/Server/Vendor/Priya/Application/Data/Cache/01/1578ee0fedd628ca8227e04bfc7b1e3917fb1833.json'
(length=106)
//$time = 1527281173
//$atime = null
( ! ) Warning: touch(): Utime failed: Operation not permitted in
/mnt/c/Library/Server/Vendor/Priya/Module/File/Class/File.class.php on line 40
Expected result:
----------------
no warning with the "fix"...
no warning with the "doesn't work"
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=76379&edit=1