From d9d883468be76b0b4e6ab88d66b0110b707f151a Mon Sep 17 00:00:00 2001 From: Felix Arntz Date: Fri, 29 Jan 2021 20:00:02 +0000 Subject: [PATCH] Security: Allow short-circuiting the `wp_update_https_detection_errors()` process. This changeset introduces a `pre_wp_update_https_detection_errors` filter which can be used to short-circuit the default logic for detecting problems with HTTPS support for the site, by returning a `WP_Error` object. Props timothyblynjacobs. See #47577. Built from https://develop.svn.wordpress.org/trunk@50075 git-svn-id: http://core.svn.wordpress.org/trunk@49775 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/https-detection.php | 17 +++++++++++++++++ wp-includes/version.php | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/wp-includes/https-detection.php b/wp-includes/https-detection.php index f6562bbca0..2ced175047 100644 --- a/wp-includes/https-detection.php +++ b/wp-includes/https-detection.php @@ -88,6 +88,23 @@ function wp_is_https_supported() { * @access private */ function wp_update_https_detection_errors() { + /** + * Short-circuits the process of detecting errors related to HTTPS support. + * + * Returning a `WP_Error` from the filter will effectively short-circuit the default logic of trying a remote + * request to the site over HTTPS, storing the errors array from the returned `WP_Error` instead. + * + * @since 5.7.0 + * + * @param null|WP_Error $pre Error object to short-circuit detection, + * or null to continue with the default behavior. + */ + $support_errors = apply_filters( 'pre_wp_update_https_detection_errors', null ); + if ( is_wp_error( $support_errors ) ) { + update_option( 'https_detection_errors', $support_errors->errors ); + return; + } + $support_errors = new WP_Error(); $response = wp_remote_request( diff --git a/wp-includes/version.php b/wp-includes/version.php index ba4b3e7e69..36ef520611 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.7-alpha-50073'; +$wp_version = '5.7-alpha-50075'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.