Bug #76379 [Com]: cant touch with $atime=null

From: Date: Sat, 26 May 2018 12:30:27 +0000
Subject: Bug #76379 [Com]: cant touch with $atime=null
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-215375@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 Comment by: spam2 at rhsoft dot net Reported by: remco at priya dot software Summary: cant touch with $atime=null Status: Not a bug Type: Bug Package: Filesystem function related Operating System: PHP 7.2.5-1+ubuntu14.04.1+deb.su PHP Version: 7.2.6 Assigned To: cmb Block user comment: N Private report: N New Comment: just use strict-mode so that you learn that you can't pass NULL to a int param Previous Comments: ------------------------------------------------------------------------ [2018-05-26 12:24:10] cmb@php.net 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> ------------------------------------------------------------------------ [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

« previous php.bugs (#215375) next »