php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #51442 is_writable is confusing, should NOT check if the file exists or not
Submitted: 2010-03-30 20:56 UTC Modified: 2010-03-30 21:44 UTC
From: mr dot mosch at gmail dot com Assigned:
Status: Wont fix Package: *Directory/Filesystem functions
PHP Version: 5.2.13 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: mr dot mosch at gmail dot com
New email:
PHP Version: OS:

 

 [2010-03-30 20:56 UTC] mr dot mosch at gmail dot com
Description:
------------
If i want to check if the file is writeable even if it not exists, if have to write an complicated function. if the behavior would change both cases, file exists and file does not exists would be handled in 1 line of code.

This is not a test script, should only show up the thing.

// Acutal behavior:
if (is_writeable('/tmp/NOT_EXISTING')) // returns false

// Better behavior:
if (is_writeable('/tmp/NOT_EXISTING')) // returns true

// Actual workaround:
if (is_writeable('/tmp/NOT_EXISTING') || (file_exists('/tmp/NOT_EXISTING') === false && is_writeable(pathinfo('/tmp/NOT_EXISTING', PATHINFO_DIRNAME))) // return true



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-03-30 21:44 UTC] fa@php.net
-Status: Open +Status: Wont fix
 [2010-03-30 21:44 UTC] fa@php.net
This would be quite a BC break, won't happen.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 16:01:29 2024 UTC