Make WordPress Core

Ticket #28616: 28616.2.patch

File 28616.2.patch, 937 bytes (added by stevenlinx, 5 years ago)
  • src/wp-admin/includes/class-wp-filesystem-ftpext.php

    diff --git a/src/wp-admin/includes/class-wp-filesystem-ftpext.php b/src/wp-admin/includes/class-wp-filesystem-ftpext.php
    index f337c73..1dfe136 100644
    a b class WP_Filesystem_FTPext extends WP_Filesystem_Base { 
    180180
    181181                fseek( $temp, 0 ); // Skip back to the start of the file being written to
    182182
    183                 $ret = @ftp_fput( $this->link, $file, $temp, FTP_BINARY );
     183                $tries = 1;
     184                $total_tries = 3;
     185                while (($ret = ftp_fput($this->link, $file, $temp, $type)) != 1 && $tries <= $total_tries)
     186                {
     187                        if($tries < $total_tries)
     188                        {
     189                                error_log("Error Uploading File. Tried $tries of $total_tries. Reconnecting...");
     190                                sleep(1);
     191                                $this->connect();
     192                        }
     193                        else
     194                                error_log("Error Uploading File. Tried $tries of $total_tries.");
     195                       
     196                        $tries++;
     197                }
    184198
    185199                fclose($temp);
    186200                unlink($tempfile);