wp-fs fixes from DD32. see #5586
git-svn-id: https://develop.svn.wordpress.org/trunk@7155 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
9266ee91aa
commit
dc6c68d79a
|
@ -13,11 +13,11 @@ class WP_Filesystem_Direct{
|
||||||
function setDefaultPermissions($perm){
|
function setDefaultPermissions($perm){
|
||||||
$this->permission = $perm;
|
$this->permission = $perm;
|
||||||
}
|
}
|
||||||
function find_base_dir($base = '.'){
|
function find_base_dir($base = '.', $echo = false){
|
||||||
return str_replace('\\','/',ABSPATH);
|
return str_replace('\\','/',ABSPATH);
|
||||||
}
|
}
|
||||||
function get_base_dir($base = '.'){
|
function get_base_dir($base = '.', $echo = false){
|
||||||
return str_replace('\\','/',ABSPATH);
|
return find_base_dir($base, $echo);
|
||||||
}
|
}
|
||||||
function get_contents($file){
|
function get_contents($file){
|
||||||
return @file_get_contents($file);
|
return @file_get_contents($file);
|
||||||
|
|
|
@ -62,9 +62,9 @@ class WP_Filesystem_FTPext{
|
||||||
|
|
||||||
function connect(){
|
function connect(){
|
||||||
if ( $this->options['ssl'] && function_exists('ftp_ssl_connect') ) {
|
if ( $this->options['ssl'] && function_exists('ftp_ssl_connect') ) {
|
||||||
$this->link = ftp_ssl_connect($this->options['hostname'], $this->options['port'],$this->timeout);
|
$this->link = @ftp_ssl_connect($this->options['hostname'], $this->options['port'],$this->timeout);
|
||||||
} else {
|
} else {
|
||||||
$this->link = ftp_connect($this->options['hostname'], $this->options['port'],$this->timeout);
|
$this->link = @ftp_connect($this->options['hostname'], $this->options['port'],$this->timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! $this->link ) {
|
if ( ! $this->link ) {
|
||||||
|
@ -72,7 +72,7 @@ class WP_Filesystem_FTPext{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! ftp_login($this->link,$this->options['username'], $this->options['password']) ) {
|
if ( ! @ftp_login($this->link,$this->options['username'], $this->options['password']) ) {
|
||||||
$this->errors->add('auth', sprintf(__('Username/Password incorrect for %s'), $this->options['username']));
|
$this->errors->add('auth', sprintf(__('Username/Password incorrect for %s'), $this->options['username']));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -119,9 +119,9 @@ class WP_Filesystem_FTPext{
|
||||||
//If we get this far, somethings gone wrong, change to / and restart the process.
|
//If we get this far, somethings gone wrong, change to / and restart the process.
|
||||||
return $this->find_base_dir('/',$echo);
|
return $this->find_base_dir('/',$echo);
|
||||||
}
|
}
|
||||||
function get_base_dir($base = '.'){
|
function get_base_dir($base = '.', $echo=false){
|
||||||
if( empty($this->wp_base) )
|
if( empty($this->wp_base) )
|
||||||
$this->wp_base = $this->find_base_dir($base);
|
$this->wp_base = $this->find_base_dir($base,$echo);
|
||||||
return $this->wp_base;
|
return $this->wp_base;
|
||||||
}
|
}
|
||||||
function get_contents($file,$type='',$resumepos=0){
|
function get_contents($file,$type='',$resumepos=0){
|
||||||
|
@ -298,7 +298,8 @@ class WP_Filesystem_FTPext{
|
||||||
}
|
}
|
||||||
function is_dir($path){
|
function is_dir($path){
|
||||||
$cwd = $this->cwd();
|
$cwd = $this->cwd();
|
||||||
if ( @ftp_chdir($this->link, $path) ) {
|
@ftp_chdir($this->link, $path);
|
||||||
|
if ( $this->cwd() != $cwd ) {
|
||||||
@ftp_chdir($this->link, $cwd);
|
@ftp_chdir($this->link, $cwd);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -325,7 +326,7 @@ class WP_Filesystem_FTPext{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
function mkdir($path,$chmod=false,$chown=false,$chgrp=false){
|
function mkdir($path,$chmod=false,$chown=false,$chgrp=false){
|
||||||
if( !ftp_mkdir($this->link, $path) )
|
if( !@ftp_mkdir($this->link, $path) )
|
||||||
return false;
|
return false;
|
||||||
if( $chmod )
|
if( $chmod )
|
||||||
$this->chmod($path, $chmod);
|
$this->chmod($path, $chmod);
|
||||||
|
@ -337,7 +338,7 @@ class WP_Filesystem_FTPext{
|
||||||
}
|
}
|
||||||
function rmdir($path,$recursive=false){
|
function rmdir($path,$recursive=false){
|
||||||
if( ! $recursive )
|
if( ! $recursive )
|
||||||
return ftp_rmdir($this->link, $file);
|
return @ftp_rmdir($this->link, $file);
|
||||||
|
|
||||||
//TODO: Recursive Directory delete, Have to delete files from the folder first.
|
//TODO: Recursive Directory delete, Have to delete files from the folder first.
|
||||||
//$dir = $this->dirlist($path);
|
//$dir = $this->dirlist($path);
|
||||||
|
|
|
@ -122,9 +122,9 @@ class WP_Filesystem_ftpsockets{
|
||||||
return $this->find_base_dir('/',$echo);
|
return $this->find_base_dir('/',$echo);
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_base_dir($base = '.'){
|
function get_base_dir($base = '.', $echo = false){
|
||||||
if( empty($this->wp_base) )
|
if( empty($this->wp_base) )
|
||||||
$this->wp_base = $this->find_base_dir($base);
|
$this->wp_base = $this->find_base_dir($base, $echo);
|
||||||
return $this->wp_base;
|
return $this->wp_base;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -140,6 +140,9 @@ function wp_update_plugin($plugin, $feedback = '') {
|
||||||
if ( $wp_filesystem->errors->get_error_code() )
|
if ( $wp_filesystem->errors->get_error_code() )
|
||||||
return new WP_Error('fs_error', __('Filesystem error'), $wp_filesystem->errors);
|
return new WP_Error('fs_error', __('Filesystem error'), $wp_filesystem->errors);
|
||||||
|
|
||||||
|
//Get the Base folder
|
||||||
|
$base = $wp_filesystem->get_base_dir();
|
||||||
|
|
||||||
// Get the URL to the zip file
|
// Get the URL to the zip file
|
||||||
$r = $current->response[ $plugin ];
|
$r = $current->response[ $plugin ];
|
||||||
|
|
||||||
|
@ -148,14 +151,14 @@ function wp_update_plugin($plugin, $feedback = '') {
|
||||||
|
|
||||||
// Download the package
|
// Download the package
|
||||||
$package = $r->package;
|
$package = $r->package;
|
||||||
apply_filters('update_feedback', __("Downloading update from $package"));
|
apply_filters('update_feedback', sprintf(__("Downloading update from %s"), $package));
|
||||||
$file = download_url($package);
|
$file = download_url($package);
|
||||||
|
|
||||||
if ( !$file )
|
if ( !$file )
|
||||||
return new WP_Error('download_failed', __('Download failed.'));
|
return new WP_Error('download_failed', __('Download failed.'));
|
||||||
|
|
||||||
$name = basename($plugin, '.php');
|
$name = basename($plugin, '.php');
|
||||||
$working_dir = ABSPATH . 'wp-content/upgrade/' . $name;
|
$working_dir = $base . 'wp-content/upgrade/' . $name;
|
||||||
|
|
||||||
// Clean up working directory
|
// Clean up working directory
|
||||||
if ( is_dir($working_dir) )
|
if ( is_dir($working_dir) )
|
||||||
|
@ -175,12 +178,13 @@ function wp_update_plugin($plugin, $feedback = '') {
|
||||||
|
|
||||||
// Remove the existing plugin.
|
// Remove the existing plugin.
|
||||||
apply_filters('update_feedback', __("Removing the old version of the plugin"));
|
apply_filters('update_feedback', __("Removing the old version of the plugin"));
|
||||||
$plugin_dir = dirname(ABSPATH . PLUGINDIR . "/$plugin");
|
$plugin_dir = dirname($base . PLUGINDIR . "/$plugin");
|
||||||
|
$plugin_dir = trailingslashit($plugin_dir);
|
||||||
// If plugin is in its own directory, recursively delete the directory.
|
// If plugin is in its own directory, recursively delete the directory.
|
||||||
if ( '.' != $plugin_dir && ABSPATH . PLUGINDIR != $plugin_dir )
|
if ( '.' != $plugin_dir && $base . PLUGINDIR != $plugin_dir )
|
||||||
$deleted = $wp_filesystem->delete($plugin_dir, true);
|
$deleted = $wp_filesystem->delete($plugin_dir, true);
|
||||||
else
|
else
|
||||||
$deleted = $wp_filesystem->delete(ABSPATH . PLUGINDIR . "/$plugin");
|
$deleted = $wp_filesystem->delete($base . PLUGINDIR . "/$plugin");
|
||||||
if ( !$deleted ) {
|
if ( !$deleted ) {
|
||||||
$wp_filesystem->delete($working_dir, true);
|
$wp_filesystem->delete($working_dir, true);
|
||||||
return new WP_Error('delete_failed', __('Could not remove the old plugin'));
|
return new WP_Error('delete_failed', __('Could not remove the old plugin'));
|
||||||
|
@ -188,7 +192,7 @@ function wp_update_plugin($plugin, $feedback = '') {
|
||||||
|
|
||||||
apply_filters('update_feedback', __("Installing the latest version"));
|
apply_filters('update_feedback', __("Installing the latest version"));
|
||||||
// Copy new version of plugin into place.
|
// Copy new version of plugin into place.
|
||||||
if ( !copy_dir($working_dir, ABSPATH . PLUGINDIR) ) {
|
if ( !copy_dir($working_dir, $base . PLUGINDIR) ) {
|
||||||
//$wp_filesystem->delete($working_dir, true);
|
//$wp_filesystem->delete($working_dir, true);
|
||||||
return new WP_Error('install_failed', __('Installation failed'));
|
return new WP_Error('install_failed', __('Installation failed'));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue