Check for write permission!

A few days ago I was making updates to my shopping list web app, reorganizing the pieces into a directory structure more logical than just “everything dumped in the top-level directory”.

After a quick round of updating all the file linking to point into the right subdirectories (including a few minutes of head-scratching to remember that I needed to prepend “..\” to hop between them), I had it partially working.

I went back and forth between the pre- and post-cleaned up revisions in git, and it seemed that no matter what I did, the cleanup broke all of my PHP scripts except the one that retrieved the list contents. All of the scripts that tried to modify the list (adding to it, removing from it, or modifying an entry) failed and didn’t do anything.

I double-checked that file paths were correct. I did copy-pasting between the working and non-working scripts to try to rule out possible causes. I even did as much line-by-line debugging as I could in Chrome, which wasn’t all that much since the failure was in the server-side PHP and not the client code.

Ultimately I had it narrowed down to a state where as far as I could tell, there was no logical difference between the retrieve script and the rest of the scripts; but still only the others failed.

Finally I realized my error:

Default permissions when I create a new folder under /Users/ in OS X

The new “/lists” ¬†subdirectory that I had created could not be written to by the server process, because by default, new directories I create don’t have that permission flag set. So it ended up being not a code issue at all, just a directory configuration problem. Something to watch for!

Leave a Reply