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
This commit is contained in:
Sergey Biryukov 2020-03-15 19:43:50 +00:00
parent a2861f1277
commit 812c92e1e9

View File

@ -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 );