Ticket #10889: 10889.2.diff
| File 10889.2.diff, 4.2 KB (added by dd32, 3 years ago) |
|---|
-
wp-admin/includes/class-wp-filesystem-direct.php
54 54 /** 55 55 * Write a string to a file 56 56 * 57 * @param $file string Path to the file where to write the data.57 * @param $file string Remote path to the file where to write the data. 58 58 * @param $contents string The data to write. 59 59 * @param $mode int (optional) The file permissions as octal number, usually 0644. 60 * @param $type string (optional) Specifies additional type of access you require to the file. 60 * @param $type string (optional) Specifies additional type of access you require to the file. Only used by the FTP transports. 61 61 * @return bool False upon failure. 62 62 */ 63 function put_contents($file, $contents, $mode = false, $type = '') {63 function put_contents($file, $contents, $mode = false, $type = null) { 64 64 if ( ! ($fp = @fopen($file, 'w' . $type)) ) 65 65 return false; 66 66 @fwrite($fp, $contents); -
wp-admin/includes/class-wp-filesystem-ftpext.php
111 111 function get_contents_array($file) { 112 112 return explode("\n", $this->get_contents($file)); 113 113 } 114 function put_contents($file, $contents, $type = '' ) { 114 115 function put_contents($file, $contents, $mode = false, $type = null ) { 115 116 if ( empty($type) ) 116 117 $type = $this->is_binary($contents) ? FTP_BINARY : FTP_ASCII; 117 118 … … 125 126 $ret = @ftp_fput($this->link, $file, $temp, $type); 126 127 127 128 fclose($temp); 129 130 $this->chmod($file, $mode); 131 128 132 return $ret; 129 133 } 130 134 function cwd() { -
wp-admin/includes/class-wp-filesystem-ftpsockets.php
115 115 return explode("\n", $this->get_contents($file) ); 116 116 } 117 117 118 function put_contents($file, $contents, $ type = '') {118 function put_contents($file, $contents, $mode = false, $type = null ) { 119 119 if ( empty($type) ) 120 120 $type = $this->is_binary($contents) ? FTP_BINARY : FTP_ASCII; 121 121 122 122 $this->ftp->SetType($type); 123 123 124 124 $temp = wp_tempnam( $file ); 125 if ( ! $temphandle = fopen($temp, 'w+') ) {125 if ( ! $temphandle = @fopen($temp, 'w+') ) { 126 126 unlink($temp); 127 127 return false; 128 128 } … … 134 134 135 135 fclose($temphandle); 136 136 unlink($temp); 137 138 $this->chmod($file, $mode); 139 137 140 return $ret; 138 141 } 139 142 -
wp-admin/includes/class-wp-filesystem-ssh2.php
160 160 return file('ssh2.sftp://' . $this->sftp_link . '/' . $file); 161 161 } 162 162 163 function put_contents($file, $contents, $ type = '') {163 function put_contents($file, $contents, $mode = false, $type = null ) { 164 164 $file = ltrim($file, '/'); 165 return false !== file_put_contents('ssh2.sftp://' . $this->sftp_link . '/' . $file, $contents); 165 $ret = file_put_contents('ssh2.sftp://' . $this->sftp_link . '/' . $file, $contents); 166 167 $this->chmod($file, $mode); 168 169 return false !== $ret; 166 170 } 167 171 168 172 function cwd() { -
wp-admin/includes/file.php
546 546 547 547 // We've made sure the folders are there, so let's extract the file now: 548 548 if ( ! $file['folder'] ) { 549 if ( !$fs->put_contents( $to . $file['filename'], $file['content'] ) )549 if ( !$fs->put_contents( $to . $file['filename'], $file['content'], FS_CHMOD_FILE) ) 550 550 return new WP_Error('copy_failed', __('Could not copy file'), $to . $file['filename']); 551 $fs->chmod($to . $file['filename'], FS_CHMOD_FILE);552 551 } 553 552 } 554 553 return true;
