php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #76379 cant touch with $atime=null
Submitted: 2018-05-25 20:50 UTC Modified: 2018-05-26 12:24 UTC
From: remco at priya dot software Assigned: cmb (profile)
Status: Not a bug Package: Filesystem function related
PHP Version: 7.2.6 OS: PHP 7.2.5-1+ubuntu14.04.1+deb.su
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
23 + 41 = ?
Subscribe to this entry?

 
 [2018-05-25 20:50 UTC] 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"


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-05-26 12:24 UTC] cmb@php.net
-Status: Open +Status: Not a bug -Package: URL related +Package: Filesystem function related -Assigned To: +Assigned To: cmb
 [2018-05-26 12:24 UTC] 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-26 12:30 UTC] spam2 at rhsoft dot net
just use strict-mode so that you learn that you can't pass NULL to a int param
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 23 09:01:27 2024 UTC