Skip to content

Commit 001a86a

Browse files
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. git-svn-id: https://develop.svn.wordpress.org/trunk@59981 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 32fe6af commit 001a86a

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/wp-admin/includes/class-wp-upgrader.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,9 +1007,17 @@ public function run( $options ) {
10071007
public function maintenance_mode( $enable = false ) {
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

10151023
$file = $wp_filesystem->abspath() . '.maintenance';

0 commit comments

Comments
 (0)