WordPress.org

Make WordPress Core

Ticket #9936: 9936.diff

File 9936.diff, 1.5 KB (added by dd32, 11 years ago)
  • wp-admin/includes/file.php

     
    626630 * @return unknown
    627631 */
    628632function get_filesystem_method($args = array()) {
    629         $method = false;
    630         if( function_exists('getmyuid') && function_exists('fileowner') ){
    631                 $temp_file = wp_tempnam();
    632                 if ( getmyuid() == fileowner($temp_file) )
     633        $method = defined('FS_METHOD') ? FS_METHOD : false; //Please ensure that this is either 'direct', 'ssh', 'ftpext' or 'ftpsockets'
     634
     635        if( ! $method && function_exists('getmyuid') && function_exists('fileowner') ){
     636                $temp_file_name = ABSPATH . '/.' . time();
     637                $temp_handle = @fopen($temp_file_name, 'w');
     638                if ( $temp_handle && getmyuid() == fileowner($temp_file_name) )
    633639                        $method = 'direct';
    634                 unlink($temp_file);
     640                @fclose($temp_handle);
     641                unlink($temp_file_name);
    635642        }
    636643
    637644        if ( ! $method && isset($args['connection_type']) && 'ssh' == $args['connection_type'] && extension_loaded('ssh2') && extension_loaded('sockets') ) $method = 'ssh2';
    638645        if ( ! $method && extension_loaded('ftp') ) $method = 'ftpext';
    639646        if ( ! $method && ( extension_loaded('sockets') || function_exists('fsockopen') ) ) $method = 'ftpsockets'; //Sockets: Socket extension; PHP Mode: FSockopen / fwrite / fread
    640         return apply_filters('filesystem_method', $method);
     647        return apply_filters('filesystem_method', $method, $args);
    641648}
    642649
    643650/**