WordPress.org

Make WordPress Core

Ticket #44429: 44429.diff

File 44429.diff, 681 bytes (added by afragen, 17 months ago)

test for WP_CLI in wp_redirect() and exit early

  • src/wp-includes/pluggable.php

    diff --git src/wp-includes/pluggable.php src/wp-includes/pluggable.php
    index cb06297b57..be94539065 100644
    if ( ! function_exists( 'wp_redirect' ) ) : 
    12051205        function wp_redirect( $location, $status = 302, $x_redirect_by = 'WordPress' ) {
    12061206                global $is_IIS;
    12071207
     1208                // Exit early when using WP-CLI.
     1209                $location_scheme = parse_url( $location, PHP_URL_SCHEME );
     1210                if ( defined( 'WP_CLI' ) && WP_CLI && 'https' === $location_scheme ) {
     1211                        return;
     1212                }
     1213
    12081214                /**
    12091215                 * Filters the redirect location.
    12101216                 *
    if ( ! function_exists( 'wp_text_diff' ) ) : 
    27332739                return $r;
    27342740        }
    27352741endif;
    2736