How to edit a file in a protected folder

  1. Open a terminal window (Applications/Utilities/Terminal)
  2. Change the current folder to the target folder (myfolder)
  3. If you want to create the target file (myfile)
    1. Type: sudo touch myfile
    2. Authenticate with the admin password
  4. If the folder is hidden in Finder, show hidden files in Finder
  5. Find and enter myfolder in Finder
  6. Drag and drop myfile from myfolder to the Desktop
  7. Edit myfile from the Desktop with any editor
  8. Save the file to the Desktop
  9. Drag and drop myfile from the Desktop to myfolder
  10. When asked, choose Replace
  11. Authenticate with the admin password

How to fix Fatal error: Exception thrown without a stack frame

From time to time I get the infamous

Fatal error: Exception thrown without a stack frame in Unknown on line 0

but googling about it yesterday I found this article that describes a method for seeing through it and discover the real error. It’s very simple and yet powerful (and it works).

The key trick is

  1. find the line N where your script is misbehaving. This is tedious but easily done with a binary search on the execution line. At the beginning, the execution line can be that of the whole script.
    • find an approximate middle point in the current execution line
    • put an exit instruction there and execute the script again
    • do you get the same error?
      • YES: make the executed half the next execution line
      • NO: make the non executed half the next execution line
    • remove the exit
    • repeat all until the exit on line N is clean and on line N+1 is dirty
  2. look at what you have on line N and try to figure out how to force your script to willfully do right there the same operations that are automatically done on shut down
    • in my case yesterday, like the author of the article, I had a session_start on line N, so that I added a session_write_close() on line N+1 and an exit on line N+2. Magically the real error message got displayed!!