Make WordPress Core

Ticket #10522: class-wp-filesystem-ftpext.php.2.patch

File class-wp-filesystem-ftpext.php.2.patch, 1.4 KB (added by ntm, 16 years ago)

changed default timeout, use timeout constant if defined, further errormessage for login timeout

  • class-wp-filesystem-ftpext.php

     
    1616 */
    1717class WP_Filesystem_FTPext extends WP_Filesystem_Base {
    1818        var $link;
    19         var $timeout = 5;
     19        var $timeout = 30;
    2020        var $errors = null;
    2121        var $options = array();
    2222
     
    4343                else
    4444                        $this->options['hostname'] = $opt['hostname'];
    4545
     46                if ( isset($opt['connect_timeout']) && ! empty($opt['connect_timeout']) && 0 < intval($opt['connect_timeout']))
     47                        $this->timeout = intval($opt['connect_timeout']);
     48
    4649                if ( isset($opt['base']) && ! empty($opt['base']) )
    4750                        $this->wp_base = $opt['base'];
    4851
     
    7376                        return false;
    7477                }
    7578
     79                $start_time = array_sum(explode(chr(32), microtime())); // this should be PHP 4 save
    7680                if ( ! @ftp_login($this->link,$this->options['username'], $this->options['password']) ) {
    77                         $this->errors->add('auth', sprintf(__('Username/Password incorrect for %s'), $this->options['username']));
     81                        $finish_time = array_sum(explode(chr(32), microtime()));
     82                        if  ( ($finish_time - $start_time) > $this->timeout ) {
     83                                $this->errors->add('auth', __('FTP login process timed out'));
     84                        } else {
     85                                $this->errors->add('auth', sprintf(__('Username/Password incorrect for %s'), $this->options['username']));
     86                        }
    7887                        return false;
    7988                }
    8089