Here’s how it checks to see if it can update files directly (without FTP):
if( function_exists('getmyuid') && function_exists('fileowner') ){
$temp_file = wp_tempnam();
if ( getmyuid() == fileowner($temp_file) )
$method = 'direct';
unlink($temp_file);
}
For the non-PHP people:
1. It checks to see if the getmyuid() and fileowner() functions are available and activated.
2. It calls wp_tempnam(). This function gets the PHP-defined temporary directory and creates a temporary empty file in it.
3. It checks to see if the owner of the just-created temp file is the same user as the owner of the update script itself. This would indicate that WordPress is running with the same credentials as the person who installed it. In other words, it checks to see if you’re running suPHP.
– Before it’s done, it deletes the temp file.
If any of these three checks fail, then you have to put in FTP credentials. This is because, in these cases, WordPress does not have enough local rights to be able to correctly overwrite its own files. So it has to get FTP info in order to FTP back to itself, as you, and thus obtain those rights. It can’t escalate its own privileges.
Short version:
1. You need to have PHP configured to allow getmyuid and fileowner to work.
2. You need to be running suPHP.
3. Your temporary file directory needs to be defined correctly.
Most normal hosting setups do this by default. Use of suPHP is fairly standard, as it’s safer from a security standpoint.