Make WordPress Core


Ignore:
Timestamp:
10/23/2015 05:53:05 AM (9 years ago)
Author:
dd32
Message:

WP_HTTP: Promote the WP_HTTP::parse_url() method to a more generic wp_parse_url() function.

Fixes #34408

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-http.php

    r34585 r35369  
    689689     * A wrapper for PHP's parse_url() function that handles edgecases in < PHP 5.4.7
    690690     *
    691      * PHP 5.4.7 expanded parse_url()'s ability to handle non-absolute url's, including
    692      * schemeless and relative url's with :// in the path, this works around those
    693      * limitations providing a standard output on PHP 5.2~5.4+.
    694      *
    695      * Error suppression is used as prior to PHP 5.3.3, an E_WARNING would be generated
    696      * when URL parsing failed.
    697      *
    698      * @since 4.1.0
    699      *
    700      * @static
    701691     * @access protected
     692     * @deprecated 4.4.0 See wp_parse_url()
    702693     *
    703694     * @param string $url The URL to parse.
     
    706697     */
    707698    protected static function parse_url( $url ) {
    708         $parts = @parse_url( $url );
    709         if ( ! $parts ) {
    710             // < PHP 5.4.7 compat, trouble with relative paths including a scheme break in the path
    711             if ( '/' == $url[0] && false !== strpos( $url, '://' ) ) {
    712                 // Since we know it's a relative path, prefix with a scheme/host placeholder and try again
    713                 if ( ! $parts = @parse_url( 'placeholder://placeholder' . $url ) ) {
    714                     return $parts;
    715                 }
    716                 // Remove the placeholder values
    717                 unset( $parts['scheme'], $parts['host'] );
    718             } else {
    719                 return $parts;
    720             }
    721         }
    722 
    723         // < PHP 5.4.7 compat, doesn't detect schemeless URL's host field
    724         if ( '//' == substr( $url, 0, 2 ) && ! isset( $parts['host'] ) ) {
    725             list( $parts['host'], $slashless_path ) = explode( '/', substr( $parts['path'], 2 ), 2 );
    726             $parts['path'] = "/{$slashless_path}";
    727         }
    728 
    729         return $parts;
     699        _deprecated_function( __METHOD__, '4.4.0', 'wp_parse_url()' );
     700        return wp_parse_url( $url );
    730701    }
    731702
     
    748719            return $maybe_relative_path;
    749720
    750         if ( ! $url_parts = WP_Http::parse_url( $url ) ) {
     721        if ( ! $url_parts = wp_parse_url( $url ) ) {
    751722            return $maybe_relative_path;
    752723        }
    753724
    754         if ( ! $relative_url_parts = WP_Http::parse_url( $maybe_relative_path ) ) {
     725        if ( ! $relative_url_parts = wp_parse_url( $maybe_relative_path ) ) {
    755726            return $maybe_relative_path;
    756727        }
Note: See TracChangeset for help on using the changeset viewer.