From fda490579033694a778e37a7ad32f4fded798b1c Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Fri, 14 Mar 2025 12:59:32 +0000 Subject: [PATCH] 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. Built from https://develop.svn.wordpress.org/trunk@59981 git-svn-id: http://core.svn.wordpress.org/trunk@59323 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/class-wp-upgrader.php | 14 +++++++++++--- wp-includes/version.php | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/wp-admin/includes/class-wp-upgrader.php b/wp-admin/includes/class-wp-upgrader.php index 6c6cb5d828..40f19f8956 100644 --- a/wp-admin/includes/class-wp-upgrader.php +++ b/wp-admin/includes/class-wp-upgrader.php @@ -1007,9 +1007,17 @@ class WP_Upgrader { public function maintenance_mode( $enable = false ) { global $wp_filesystem; - if ( ! $wp_filesystem ) { - require_once ABSPATH . 'wp-admin/includes/file.php'; - WP_Filesystem(); + if ( ! function_exists( 'WP_Filesystem' ) ) { + require_once ABSPATH . '/wp-admin/includes/file.php'; + } + + ob_start(); + $credentials = request_filesystem_credentials( '' ); + ob_end_clean(); + + if ( false === $credentials || ! WP_Filesystem( $credentials ) ) { + wp_trigger_error( __FUNCTION__, __( 'Could not access filesystem.' ) ); + return; } $file = $wp_filesystem->abspath() . '.maintenance'; diff --git a/wp-includes/version.php b/wp-includes/version.php index 589b5d3b3a..a2e18650d5 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.8-beta2-59980'; +$wp_version = '6.8-beta2-59981'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.