|  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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
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
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: Sat Sep 23 09:01:24 2023 UTC