Make WordPress Core

Changeset 60107


Ignore:
Timestamp:
03/30/2025 07:25:35 PM (4 weeks 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 SirLouen, hideishi, dd32, tusharaddweb, takuword, SergeyBiryukov.
Fixes #62718.

File:
1 edited

Legend:

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

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