Make WordPress Core


Ignore:
Timestamp:
08/01/2023 04:05:23 PM (3 years ago)
Author:
SergeyBiryukov
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/update.php

    r56276 r56341  
    11141114    global $wp_filesystem;
    11151115
    1116     if ( ! $wp_filesystem ) {
     1116    if ( ! function_exists( 'WP_Filesystem' ) ) {
    11171117        require_once ABSPATH . '/wp-admin/includes/file.php';
    1118         WP_Filesystem();
     1118    }
     1119
     1120    ob_start();
     1121    $credentials = request_filesystem_credentials( '' );
     1122    ob_end_clean();
     1123
     1124    if ( false === $credentials || ! WP_Filesystem( $credentials ) ) {
     1125        return new WP_Error( 'fs_unavailable', __( 'Could not access filesystem.' ) );
    11191126    }
    11201127
Note: See TracChangeset for help on using the changeset viewer.