Make WordPress Core

Changeset 59981


Ignore:
Timestamp:
03/14/2025 12:57:10 PM (5 months ago)
Author:
SergeyBiryukov
Message:

Upgrade/Install: Pass stored credentials to WP_Filesystem() in WP_Upgrader.

When using a non-direct filesystem, the call in WP_Upgrader::maintenance_mode() did not include the required credentials, leading to a fatal error as the connection was not initialized properly.

This commit attempts to use the stored credentials if available, and triggers a notice otherwise.

Follow-up to [56341], [58128].

Props hideishi, dd32, SergeyBiryukov.
Fixes #62718.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-upgrader.php

    r59861 r59981  
    10081008        global $wp_filesystem;
    10091009
    1010         if ( ! $wp_filesystem ) {
    1011             require_once ABSPATH . 'wp-admin/includes/file.php';
    1012             WP_Filesystem();
     1010        if ( ! function_exists( 'WP_Filesystem' ) ) {
     1011            require_once ABSPATH . '/wp-admin/includes/file.php';
     1012        }
     1013
     1014        ob_start();
     1015        $credentials = request_filesystem_credentials( '' );
     1016        ob_end_clean();
     1017
     1018        if ( false === $credentials || ! WP_Filesystem( $credentials ) ) {
     1019            wp_trigger_error( __FUNCTION__, __( 'Could not access filesystem.' ) );
     1020            return;
    10131021        }
    10141022
Note: See TracChangeset for help on using the changeset viewer.