mirror of
git://develop.git.wordpress.org/
synced 2025-04-07 13:43:25 +02:00
Upgrade/Install: Pass stored credentials to WP_Filesystem()
where appropriate.
With the introduction of temporary backups of plugins and themes before updating, a new Site Health test was added to verify that plugin and theme temporary backup directories are writable or can be created. When using a non-direct filesystem, the Site Health test did not include the required credentials, leading to a fatal error as the connection was not initialized properly. This commit attemps to use the stored credentials if available, and displays a message otherwise. Includes a similar fix in a function that performs a cleanup of the temporary backup directory. Follow-up to [55720]. Props utsav72640, rajinsharwar, costdev, mukesh27, peterwilsoncc, audrasjb, SergeyBiryukov. Reviewed by audrasjb, SergeyBiryukov. Merges [56341] to the 6.3 branch. See #58940. git-svn-id: https://develop.svn.wordpress.org/branches/6.3@56342 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
5ae26c62a7
commit
166b55a12b
@ -2009,9 +2009,19 @@ class WP_Site_Health {
|
||||
'test' => 'update_temp_backup_writable',
|
||||
);
|
||||
|
||||
if ( ! $wp_filesystem ) {
|
||||
if ( ! function_exists( 'WP_Filesystem' ) ) {
|
||||
require_once ABSPATH . '/wp-admin/includes/file.php';
|
||||
WP_Filesystem();
|
||||
}
|
||||
|
||||
ob_start();
|
||||
$credentials = request_filesystem_credentials( '' );
|
||||
ob_end_clean();
|
||||
|
||||
if ( false === $credentials || ! WP_Filesystem( $credentials ) ) {
|
||||
$result['status'] = 'recommended';
|
||||
$result['label'] = __( 'Could not access filesystem' );
|
||||
$result['description'] = __( 'Unable to connect to the filesystem. Please confirm your credentials.' );
|
||||
return $result;
|
||||
}
|
||||
|
||||
$wp_content = $wp_filesystem->wp_content_dir();
|
||||
|
@ -1113,9 +1113,16 @@ function wp_delete_all_temp_backups() {
|
||||
function _wp_delete_all_temp_backups() {
|
||||
global $wp_filesystem;
|
||||
|
||||
if ( ! $wp_filesystem ) {
|
||||
if ( ! function_exists( 'WP_Filesystem' ) ) {
|
||||
require_once ABSPATH . '/wp-admin/includes/file.php';
|
||||
WP_Filesystem();
|
||||
}
|
||||
|
||||
ob_start();
|
||||
$credentials = request_filesystem_credentials( '' );
|
||||
ob_end_clean();
|
||||
|
||||
if ( false === $credentials || ! WP_Filesystem( $credentials ) ) {
|
||||
return new WP_Error( 'fs_unavailable', __( 'Could not access filesystem.' ) );
|
||||
}
|
||||
|
||||
if ( ! $wp_filesystem->wp_content_dir() ) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user