From 812c92e1e99ea5ee73d6e501cc69c78782d7ad9e Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sun, 15 Mar 2020 19:43:50 +0000 Subject: [PATCH] Administration: When editing a plugin or theme file, close any active PHP session. This prevents HTTP requests from timing out when attempting to connect back to the site. Props bruandet, vjik, donmhico, SergeyBiryukov. Fixes #43358. git-svn-id: https://develop.svn.wordpress.org/trunk@47457 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/file.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/wp-admin/includes/file.php b/src/wp-admin/includes/file.php index edfdef5756..5b11a07f6d 100644 --- a/src/wp-admin/includes/file.php +++ b/src/wp-admin/includes/file.php @@ -550,6 +550,13 @@ function wp_edit_theme_plugin_file( $args ) { } else { $url = admin_url(); } + + if ( PHP_SESSION_ACTIVE === session_status() ) { + // Close any active session to prevent HTTP requests from timing out + // when attempting to connect back to the site. + session_write_close(); + } + $url = add_query_arg( $scrape_params, $url ); $r = wp_remote_get( $url, compact( 'cookies', 'headers', 'timeout', 'sslverify' ) ); $body = wp_remote_retrieve_body( $r );