diff --git a/wp-admin/includes/class-wp-filesystem-ftpext.php b/wp-admin/includes/class-wp-filesystem-ftpext.php
index fb326e1862..792dae8e0e 100644
--- a/wp-admin/includes/class-wp-filesystem-ftpext.php
+++ b/wp-admin/includes/class-wp-filesystem-ftpext.php
@@ -95,20 +95,18 @@ class WP_Filesystem_FTPext{
//Set up the base directory (Which unless specified, is the current one)
if( empty( $base ) || '.' == $base ) $base = $this->cwd();
$base = trailingslashit($base);
-
+
//Can we see the Current directory as part of the ABSPATH?
$location = strpos($abspath, $base);
if( false !== $location ){
$newbase = path_join($base, substr($abspath, $location + strlen($base)));
-
- if($echo) printf( __('Changing to %s') . '
', $newbase );
+
if( false !== $this->chdir($newbase) ){ //chdir sometimes returns null under certain circumstances, even when its changed correctly, FALSE will be returned if it doesnt change correctly.
- $base = $newbase;
+ if($echo) printf( __('Changing to %s') . '
', $newbase );
//Check to see if it exists in that folder.
- if( $this->exists($base . 'wp-settings.php') ){
- if($echo) printf( __('Found %s'), $base . 'wp-settings.php
' );
- $this->wp_base = $base;
- return $this->wp_base;
+ if( $this->exists($newbase . 'wp-settings.php') ){
+ if($echo) printf( __('Found %s'), $newbase . 'wp-settings.php
' );
+ return $newbase;
}
}
}
@@ -133,6 +131,11 @@ class WP_Filesystem_FTPext{
return $ret;
}
}
+ //Only check this as a last resort, to prevent locating the incorrect install. All above proceeedures will fail quickly if this is the right branch to take.
+ if(isset( $files[ 'wp-settings.php' ]) ){
+ if($echo) printf( __('Found %s'), $base . 'wp-settings.php
' );
+ return $base;
+ }
return false;
}
diff --git a/wp-admin/includes/class-wp-filesystem-ftpsockets.php b/wp-admin/includes/class-wp-filesystem-ftpsockets.php
index 80d22b20dc..fbac7b7e41 100644
--- a/wp-admin/includes/class-wp-filesystem-ftpsockets.php
+++ b/wp-admin/includes/class-wp-filesystem-ftpsockets.php
@@ -97,20 +97,18 @@ class WP_Filesystem_ftpsockets{
//Set up the base directory (Which unless specified, is the current one)
if( empty( $base ) || '.' == $base ) $base = $this->cwd();
$base = trailingslashit($base);
-
+
//Can we see the Current directory as part of the ABSPATH?
$location = strpos($abspath, $base);
if( false !== $location ){
$newbase = path_join($base, substr($abspath, $location + strlen($base)));
-
- if($echo) printf( __('Changing to %s') . '
', $newbase );
+
if( false !== $this->chdir($newbase) ){ //chdir sometimes returns null under certain circumstances, even when its changed correctly, FALSE will be returned if it doesnt change correctly.
- $base = $newbase;
+ if($echo) printf( __('Changing to %s') . '
', $newbase );
//Check to see if it exists in that folder.
- if( $this->exists($base . 'wp-settings.php') ){
- if($echo) printf( __('Found %s'), $base . 'wp-settings.php
' );
- $this->wp_base = $base;
- return $this->wp_base;
+ if( $this->exists($newbase . 'wp-settings.php') ){
+ if($echo) printf( __('Found %s'), $newbase . 'wp-settings.php
' );
+ return $newbase;
}
}
}
@@ -135,6 +133,11 @@ class WP_Filesystem_ftpsockets{
return $ret;
}
}
+ //Only check this as a last resort, to prevent locating the incorrect install. All above proceeedures will fail quickly if this is the right branch to take.
+ if(isset( $files[ 'wp-settings.php' ]) ){
+ if($echo) printf( __('Found %s'), $base . 'wp-settings.php
' );
+ return $base;
+ }
return false;
}