Make WordPress Core


Ignore:
Timestamp:
09/22/2023 07:06:45 PM (3 years ago)
Author:
adamsilverstein
Message:

Security: remove the cron event that checked for https support.

Fix an issue where a cron job ran every 12 hours to check for https support - even when https support was already enabled. The check is now run only when the user visits the Site Health page. Reducing the unneeded requests lowers the impact and load of hosting WordPress sites.

The wp_update_https_detection_errors function is deprecated and the https_detection_errors option that was previously set by the cron job is no longer maintained. The pre_wp_update_https_detection_errors filter is deprecated and replaced by the pre_wp_get_https_detection_errors filter which serves the same function.

Props audrasjb, johnbillion, Michi91.
Fixes #58494.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/https-detection.php

    r56191 r56664  
    8787 * This internal function is called by a regular Cron hook to ensure HTTPS support is detected and maintained.
    8888 *
    89  * @since 5.7.0
     89 * @since 6.4.0
    9090 * @access private
    9191 */
    92 function wp_update_https_detection_errors() {
     92function wp_get_https_detection_errors() {
    9393        /**
    9494         * Short-circuits the process of detecting errors related to HTTPS support.
    … …  
    9797         * request to the site over HTTPS, storing the errors array from the returned `WP_Error` instead.
    9898         *
    99          * @since 5.7.0
     99         * @since 6.4.0
    100100         *
    101101         * @param null|WP_Error $pre Error object to short-circuit detection,
    102102         *                           or null to continue with the default behavior.
     103         * @return null|WP_Error Error object if HTTPS detection errors are found, null otherwise.
    103104         */
    104         $support_errors = apply_filters( 'pre_wp_update_https_detection_errors', null );
     105        $support_errors = apply_filters( 'pre_wp_get_https_detection_errors', null );
    105106        if ( is_wp_error( $support_errors ) ) {
    106                 update_option( 'https_detection_errors', $support_errors->errors );
    107                 return;
     107                return $support_errors->errors;
    108108        }
    109109
    … …  
    154154        }
    155155
    156         update_option( 'https_detection_errors', $support_errors->errors );
    157 }
    158 
    159 /**
    160  * Schedules the Cron hook for detecting HTTPS support.
    161  *
    162  * @since 5.7.0
    163  * @access private
    164  */
    165 function wp_schedule_https_detection() {
    166         if ( wp_installing() ) {
    167                 return;
    168         }
    169 
    170         if ( ! wp_next_scheduled( 'wp_https_detection' ) ) {
    171                 wp_schedule_event( time(), 'twicedaily', 'wp_https_detection' );
    172         }
    173 }
    174 
    175 /**
    176  * Disables SSL verification if the 'cron_request' arguments include an HTTPS URL.
    177  *
    178  * This prevents an issue if HTTPS breaks, where there would be a failed attempt to verify HTTPS.
    179  *
    180  * @since 5.7.0
    181  * @access private
    182  *
    183  * @param array $request The cron request arguments.
    184  * @return array The filtered cron request arguments.
    185  */
    186 function wp_cron_conditionally_prevent_sslverify( $request ) {
    187         if ( 'https' === wp_parse_url( $request['url'], PHP_URL_SCHEME ) ) {
    188                 $request['args']['sslverify'] = false;
    189         }
    190         return $request;
     156        return $support_errors->errors;
    191157}
    192158
Note: See TracChangeset for help on using the changeset viewer.