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. See #58940. Built from https://develop.svn.wordpress.org/trunk@56341 git-svn-id: http://core.svn.wordpress.org/trunk@55853 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
4a6971f99c
commit
1364db92bb
|
@ -2009,9 +2009,19 @@ class WP_Site_Health {
|
||||||
'test' => 'update_temp_backup_writable',
|
'test' => 'update_temp_backup_writable',
|
||||||
);
|
);
|
||||||
|
|
||||||
if ( ! $wp_filesystem ) {
|
if ( ! function_exists( 'WP_Filesystem' ) ) {
|
||||||
require_once ABSPATH . '/wp-admin/includes/file.php';
|
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();
|
$wp_content = $wp_filesystem->wp_content_dir();
|
||||||
|
|
|
@ -1113,9 +1113,16 @@ function wp_delete_all_temp_backups() {
|
||||||
function _wp_delete_all_temp_backups() {
|
function _wp_delete_all_temp_backups() {
|
||||||
global $wp_filesystem;
|
global $wp_filesystem;
|
||||||
|
|
||||||
if ( ! $wp_filesystem ) {
|
if ( ! function_exists( 'WP_Filesystem' ) ) {
|
||||||
require_once ABSPATH . '/wp-admin/includes/file.php';
|
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() ) {
|
if ( ! $wp_filesystem->wp_content_dir() ) {
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '6.4-alpha-56339';
|
$wp_version = '6.4-alpha-56341';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue