Make WordPress Core

Changeset 60184


Ignore:
Timestamp:
04/24/2025 11:16:41 PM (7 months ago)
Author:
jorbin
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].

Reviewed by jorbin.
Merges [60107] to the 6.8 branch.

Props SirLouen, hideishi, dd32, tusharaddweb, takuword, SergeyBiryukov.
Fixes #62718.

Location:
branches/6.8
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/6.8

  • branches/6.8/src/wp-admin/includes/class-wp-upgrader.php

    r59982 r60184  
    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.