<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre, #msg p { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[11823] trunk/wp-admin/includes: Add constants for ftp connections timeouts
 , props dd32, see #10522</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/11823">11823</a></dd>
<dt>Author</dt> <dd>azaozz</dd>
<dt>Date</dt> <dd>2009-08-15 12:01:04 +0000 (Sat, 15 Aug 2009)</dd>
</dl>

<h3>Log Message</h3>
<pre>Add constants for ftp connections timeouts, props dd32, see <a href="http://trac.wordpress.org/ticket/10522">#10522</a></pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadminincludesclasswpfilesystemftpextphp">trunk/wp-admin/includes/class-wp-filesystem-ftpext.php</a></li>
<li><a href="#trunkwpadminincludesclasswpfilesystemftpsocketsphp">trunk/wp-admin/includes/class-wp-filesystem-ftpsockets.php</a></li>
<li><a href="#trunkwpadminincludesclasswpfilesystemssh2php">trunk/wp-admin/includes/class-wp-filesystem-ssh2.php</a></li>
<li><a href="#trunkwpadminincludesfilephp">trunk/wp-admin/includes/file.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadminincludesclasswpfilesystemftpextphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/class-wp-filesystem-ftpext.php (11822 => 11823)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/class-wp-filesystem-ftpext.php        2009-08-15 10:57:56 UTC (rev 11822)
+++ trunk/wp-admin/includes/class-wp-filesystem-ftpext.php        2009-08-15 12:01:04 UTC (rev 11823)
</span><span class="lines">@@ -16,7 +16,6 @@
</span><span class="cx">  */
</span><span class="cx"> class WP_Filesystem_FTPext extends WP_Filesystem_Base {
</span><span class="cx">         var $link;
</span><del>-        var $timeout = 5;
</del><span class="cx">         var $errors = null;
</span><span class="cx">         var $options = array();
</span><span class="cx"> 
</span><span class="lines">@@ -33,6 +32,11 @@
</span><span class="cx">                 }
</span><span class="cx"> 
</span><span class="cx">                 // Set defaults:
</span><ins>+                //This Class uses the timeout on a per-connection basis, Others use it on a per-action basis.
+
+                if ( ! defined('FS_TIMEOUT') )
+                        define('FS_TIMEOUT', 240);
+
</ins><span class="cx">                 if ( empty($opt['port']) )
</span><span class="cx">                         $this-&gt;options['port'] = 21;
</span><span class="cx">                 else
</span><span class="lines">@@ -64,9 +68,9 @@
</span><span class="cx"> 
</span><span class="cx">         function connect() {
</span><span class="cx">                 if ( isset($this-&gt;options['ssl']) &amp;&amp; $this-&gt;options['ssl'] &amp;&amp; function_exists('ftp_ssl_connect') )
</span><del>-                        $this-&gt;link = @ftp_ssl_connect($this-&gt;options['hostname'], $this-&gt;options['port'], $this-&gt;timeout);
</del><ins>+                        $this-&gt;link = @ftp_ssl_connect($this-&gt;options['hostname'], $this-&gt;options['port'], FS_CONNECT_TIMEOUT);
</ins><span class="cx">                 else
</span><del>-                        $this-&gt;link = @ftp_connect($this-&gt;options['hostname'], $this-&gt;options['port'], $this-&gt;timeout);
</del><ins>+                        $this-&gt;link = @ftp_connect($this-&gt;options['hostname'], $this-&gt;options['port'], FS_CONNECT_TIMEOUT);
</ins><span class="cx"> 
</span><span class="cx">                 if ( ! $this-&gt;link ) {
</span><span class="cx">                         $this-&gt;errors-&gt;add('connect', sprintf(__('Failed to connect to FTP Server %1$s:%2$s'), $this-&gt;options['hostname'], $this-&gt;options['port']));
</span><span class="lines">@@ -80,6 +84,8 @@
</span><span class="cx"> 
</span><span class="cx">                 //Set the Connection to use Passive FTP
</span><span class="cx">                 @ftp_pasv( $this-&gt;link, true );
</span><ins>+                if ( @ftp_get_option($this-&gt;link, FTP_TIMEOUT_SEC) &lt; FTP_TIMEOUT )
+                        @ftp_set_option($this-&gt;link, FTP_TIMEOUT_SEC, FTP_TIMEOUT);
</ins><span class="cx"> 
</span><span class="cx">                 return true;
</span><span class="cx">         }
</span></span></pre></div>
<a id="trunkwpadminincludesclasswpfilesystemftpsocketsphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/class-wp-filesystem-ftpsockets.php (11822 => 11823)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/class-wp-filesystem-ftpsockets.php        2009-08-15 10:57:56 UTC (rev 11822)
+++ trunk/wp-admin/includes/class-wp-filesystem-ftpsockets.php        2009-08-15 12:01:04 UTC (rev 11823)
</span><span class="lines">@@ -16,7 +16,6 @@
</span><span class="cx">  */
</span><span class="cx"> class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
</span><span class="cx">         var $ftp = false;
</span><del>-        var $timeout = 5;
</del><span class="cx">         var $errors = null;
</span><span class="cx">         var $options = array();
</span><span class="cx"> 
</span><span class="lines">@@ -61,12 +60,13 @@
</span><span class="cx">                 if ( ! $this-&gt;ftp )
</span><span class="cx">                         return false;
</span><span class="cx"> 
</span><del>-                //$this-&gt;ftp-&gt;Verbose = true;
</del><ins>+                $this-&gt;ftp-&gt;setTimeout(FS_CONNECT_TIMEOUT);
</ins><span class="cx"> 
</span><span class="cx">                 if ( ! $this-&gt;ftp-&gt;SetServer($this-&gt;options['hostname'], $this-&gt;options['port']) ) {
</span><span class="cx">                         $this-&gt;errors-&gt;add('connect', sprintf(__('Failed to connect to FTP Server %1$s:%2$s'), $this-&gt;options['hostname'], $this-&gt;options['port']));
</span><span class="cx">                         return false;
</span><span class="cx">                 }
</span><ins>+
</ins><span class="cx">                 if ( ! $this-&gt;ftp-&gt;connect() ) {
</span><span class="cx">                         $this-&gt;errors-&gt;add('connect', sprintf(__('Failed to connect to FTP Server %1$s:%2$s'), $this-&gt;options['hostname'], $this-&gt;options['port']));
</span><span class="cx">                         return false;
</span><span class="lines">@@ -79,6 +79,7 @@
</span><span class="cx"> 
</span><span class="cx">                 $this-&gt;ftp-&gt;SetType(FTP_AUTOASCII);
</span><span class="cx">                 $this-&gt;ftp-&gt;Passive(true);
</span><ins>+                $this-&gt;ftp-&gt;setTimeout(FS_TIMEOUT);
</ins><span class="cx">                 return true;
</span><span class="cx">         }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkwpadminincludesclasswpfilesystemssh2php"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/class-wp-filesystem-ssh2.php (11822 => 11823)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/class-wp-filesystem-ssh2.php        2009-08-15 10:57:56 UTC (rev 11822)
+++ trunk/wp-admin/includes/class-wp-filesystem-ssh2.php        2009-08-15 12:01:04 UTC (rev 11823)
</span><span class="lines">@@ -45,14 +45,6 @@
</span><span class="cx">         var $link = false;
</span><span class="cx">         var $sftp_link = false;
</span><span class="cx">         var $keys = false;
</span><del>-        /*
-         * This is the timeout value for ssh results.
-         * Slower servers might need this incressed, but this number otherwise should not change.
-         *
-         * @parm $timeout int
-         *
-         */
-        var $timeout = 15;
</del><span class="cx">         var $errors = array();
</span><span class="cx">         var $options = array();
</span><span class="cx"> 
</span><span class="lines">@@ -148,7 +140,7 @@
</span><span class="cx">                         $this-&gt;errors-&gt;add('command', sprintf(__('Unable to perform command: %s'), $command));
</span><span class="cx">                 } else {
</span><span class="cx">                         stream_set_blocking( $stream, true );
</span><del>-                        stream_set_timeout( $stream, $this-&gt;timeout );
</del><ins>+                        stream_set_timeout( $stream, FS_TIMEOUT );
</ins><span class="cx">                         $data = stream_get_contents( $stream );
</span><span class="cx">                         fclose( $stream );
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkwpadminincludesfilephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/file.php (11822 => 11823)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/file.php        2009-08-15 10:57:56 UTC (rev 11822)
+++ trunk/wp-admin/includes/file.php        2009-08-15 12:01:04 UTC (rev 11823)
</span><span class="lines">@@ -605,6 +605,12 @@
</span><span class="cx"> 
</span><span class="cx">         $wp_filesystem = new $method($args);
</span><span class="cx"> 
</span><ins>+        //Define the timeouts for the connections. Only available after the construct is called to allow for per-transport overriding of the default.
+        if ( ! defined('FS_CONNECT_TIMEOUT') )
+                define('FS_CONNECT_TIMEOUT', 30);
+        if ( ! defined('FS_TIMEOUT') )
+                define('FS_TIMEOUT', 30);
+
</ins><span class="cx">         if ( is_wp_error($wp_filesystem-&gt;errors) &amp;&amp; $wp_filesystem-&gt;errors-&gt;get_error_code() )
</span><span class="cx">                 return false;
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>