Also, if you are paranoid about permissions like I am… you need to do another recursive chmod’ing back to 755 or whatever you’d like when you’re done. Kind of takes the fun out of an “automatic plugin upgrade” but it is easier than downloading, unpacking, and reuploading.
WordPress normally does a “direct” method to access files when doing the upgrade, but it does have alternate methods.
The main other method is FTP. It will make an FTP connection back to itself and put the files in that way. This bypasses permission problems if you’d like to use it in this way.
Normally, it only uses this when it detects that files it creates have the wrong owner name, but you can modify the code to force it. Edit the wp-admin/includes/file.php file. At the end of the file, you’ll find this function:
function get_filesystem_method() {
...
Modify it to this:
function get_filesystem_method() {
/* $tempFile = tempnam(get_temp_dir(), 'WPU');
if ( getmyuid() == fileowner($tempFile) ) {
unlink($tempFile);
return 'direct';
} else {
unlink($tempFile);
}
*/
if ( extension_loaded('ftp') ) return 'ftpext';
if ( extension_loaded('sockets') || function_exists('fsockopen') ) return 'ftpsockets'; //Sockets: Socket extension; PHP Mode: FSockopen / fwrite / fread
return false;
}
All I did was to remove the “direct” check. Now it’ll be forced to use FTP, if that is available to it.