|  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:
Solve the problem:
8 - 3 = ?
Subscribe to this entry?

 [2010-03-30 20:56 UTC] mr dot mosch at gmail dot com
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


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-03-30 21:44 UTC]
-Status: Open +Status: Wont fix
 [2010-03-30 21:44 UTC]
This would be quite a BC break, won't happen.
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Thu Oct 05 00:01:24 2023 UTC