Make WordPress Core

Changeset 56342


Ignore:
Timestamp:
08/01/2023 04:08:16 PM (15 months 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.
Reviewed by audrasjb, SergeyBiryukov.
Merges [56341] to the 6.3 branch.
See #58940.

Location:
branches/6.3
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/6.3

  • branches/6.3/src/wp-admin/includes/class-wp-site-health.php

    r56211 r56342  
    20102010        );
    20112011
    2012         if ( ! $wp_filesystem ) {
     2012        if ( ! function_exists( 'WP_Filesystem' ) ) {
    20132013            require_once ABSPATH . '/wp-admin/includes/file.php';
    2014             WP_Filesystem();
     2014        }
     2015
     2016        ob_start();
     2017        $credentials = request_filesystem_credentials( '' );
     2018        ob_end_clean();
     2019
     2020        if ( false === $credentials || ! WP_Filesystem( $credentials ) ) {
     2021            $result['status']      = 'recommended';
     2022            $result['label']       = __( 'Could not access filesystem' );
     2023            $result['description'] = __( 'Unable to connect to the filesystem. Please confirm your credentials.' );
     2024            return $result;
    20152025        }
    20162026
  • branches/6.3/src/wp-includes/update.php

    r56050 r56342  
    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.