This is effective but unfortunately there is already malware that plants itself inside the database. If you are able to execute code remotely you can also almost always write to /tmp
Yes, but code being written to data areas (or rather, written/stored in such a way that it can/will be executed later) generally is a bug. Allowing a server to overwrite itself is just a bad idea (hence the NX bit for memory).
Granted, I generally don't do php, and cerainly not wordpress -- but with all these php projects having a run-once-magically-write-a-config-php-thingy -- they also generally throw a warning if that config is writable after initial setup.
Do the chgrp-dance when installing/upgrading: chgrp www-data -R php-dir;chmod g+rwX -R php-dir;#set up via web installer;chmod g-w -R php-dir;chgrp not-the-web-server -R php-dir; #fix permissions on any upload-folders