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
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 — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
40 + 35 = ?
Subscribe to this entry?

 
 [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: Sun Jun 16 19:01:30 2024 UTC