Tips and tricks for LAMP (Linux Apache MySQL PHP) developers.

When I cant find a suitable solution to a problem and have to work it out for myself I'll post the result here so hopefully others will find it useful. (All code is offered in good faith. It may not be the best solution, just a solution).

Saturday, 10 October 2009

No disk space causes random errors

I'm sure most of you are aware of this but it's something that always takes me a long time to remember.

Whenever you have a seemingly random error on your Linux box - strange MySQL or Apache errors, being unable to write to a file that you could write to a moment ago, etc - always do a quick df -h to check how much disk space you've got left.

This problem is especially evident for those of us developing on virtual machines that often have limited disk space and so can run out easily. A quick recce of your /var/log/ (or equivalent) directory is a good starting point for freeing up space but you may also want to try find / -type f -size +50000k

Wednesday, 12 August 2009

ExtJS Store Reset

I recently discovered something rather annoying about ExtJS Stores.
You may know that you can request all of the modified Records from a Store with something like:

var arr_modified = obj_store.getModifiedRecords();

This can be very useful if you have a lot of Records but only want to perform actions on the ones that have been edited by the user.
However, what I didn't realise is that the modified Records are held separately so that if you empty the Store (by calling removeAll()) and repopulate it then call getModifedRecords() again not only do you get any modified Records from the new batch but from the old batch also.

The remedy to this is quite simple, upon emptying the Store you must also call rejectChanges() which clears the cache of changed Records (this is complimentary to commitChanges() which performs basically the same action but for a different reason).

Friday, 6 February 2009

"shell_exec(): Unable to execute"

I spent ages trying to get round this PHP warning today:

"PHP Warning: shell_exec(): Unable to execute '[any bash command]'"

I hadn't changed anything and it was working 5mins before so what was wrong?

A colleague of mine suggested restarting Apache... and it worked!
I don't fully understand why, something to do with Apache running out of resources or something. Anywho, thought it might be useful for someone.