Make WordPress Core

Changeset 11823


Ignore:
Timestamp:
08/15/2009 12:01:04 PM (15 years ago)
Author:
azaozz
Message:

Add constants for ftp connections timeouts, props dd32, see #10522

Location:
trunk/wp-admin/includes
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/class-wp-filesystem-ftpext.php

    r11821 r11823  
    1717class WP_Filesystem_FTPext extends WP_Filesystem_Base {
    1818    var $link;
    19     var $timeout = 5;
    2019    var $errors = null;
    2120    var $options = array();
     
    3433
    3534        // Set defaults:
     35        //This Class uses the timeout on a per-connection basis, Others use it on a per-action basis.
     36
     37        if ( ! defined('FS_TIMEOUT') )
     38            define('FS_TIMEOUT', 240);
     39
    3640        if ( empty($opt['port']) )
    3741            $this->options['port'] = 21;
     
    6569    function connect() {
    6670        if ( isset($this->options['ssl']) && $this->options['ssl'] && function_exists('ftp_ssl_connect') )
    67             $this->link = @ftp_ssl_connect($this->options['hostname'], $this->options['port'], $this->timeout);
    68         else
    69             $this->link = @ftp_connect($this->options['hostname'], $this->options['port'], $this->timeout);
     71            $this->link = @ftp_ssl_connect($this->options['hostname'], $this->options['port'], FS_CONNECT_TIMEOUT);
     72        else
     73            $this->link = @ftp_connect($this->options['hostname'], $this->options['port'], FS_CONNECT_TIMEOUT);
    7074
    7175        if ( ! $this->link ) {
     
    8185        //Set the Connection to use Passive FTP
    8286        @ftp_pasv( $this->link, true );
     87        if ( @ftp_get_option($this->link, FTP_TIMEOUT_SEC) < FTP_TIMEOUT )
     88            @ftp_set_option($this->link, FTP_TIMEOUT_SEC, FTP_TIMEOUT);
    8389
    8490        return true;
  • trunk/wp-admin/includes/class-wp-filesystem-ftpsockets.php

    r11005 r11823  
    1717class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
    1818    var $ftp = false;
    19     var $timeout = 5;
    2019    var $errors = null;
    2120    var $options = array();
     
    6261            return false;
    6362
    64         //$this->ftp->Verbose = true;
     63        $this->ftp->setTimeout(FS_CONNECT_TIMEOUT);
    6564
    6665        if ( ! $this->ftp->SetServer($this->options['hostname'], $this->options['port']) ) {
     
    6867            return false;
    6968        }
     69
    7070        if ( ! $this->ftp->connect() ) {
    7171            $this->errors->add('connect', sprintf(__('Failed to connect to FTP Server %1$s:%2$s'), $this->options['hostname'], $this->options['port']));
     
    8080        $this->ftp->SetType(FTP_AUTOASCII);
    8181        $this->ftp->Passive(true);
     82        $this->ftp->setTimeout(FS_TIMEOUT);
    8283        return true;
    8384    }
  • trunk/wp-admin/includes/class-wp-filesystem-ssh2.php

    r11818 r11823  
    4646    var $sftp_link = false;
    4747    var $keys = false;
    48     /*
    49      * This is the timeout value for ssh results.
    50      * Slower servers might need this incressed, but this number otherwise should not change.
    51      *
    52      * @parm $timeout int
    53      *
    54      */
    55     var $timeout = 15;
    5648    var $errors = array();
    5749    var $options = array();
     
    149141        } else {
    150142            stream_set_blocking( $stream, true );
    151             stream_set_timeout( $stream, $this->timeout );
     143            stream_set_timeout( $stream, FS_TIMEOUT );
    152144            $data = stream_get_contents( $stream );
    153145            fclose( $stream );
  • trunk/wp-admin/includes/file.php

    r11819 r11823  
    606606    $wp_filesystem = new $method($args);
    607607
     608    //Define the timeouts for the connections. Only available after the construct is called to allow for per-transport overriding of the default.
     609    if ( ! defined('FS_CONNECT_TIMEOUT') )
     610        define('FS_CONNECT_TIMEOUT', 30);
     611    if ( ! defined('FS_TIMEOUT') )
     612        define('FS_TIMEOUT', 30);
     613
    608614    if ( is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code() )
    609615        return false;
Note: See TracChangeset for help on using the changeset viewer.