Code Modernization: Remove error suppression from `parse_url()` calls.
Previously, the `@` operator was used to prevent possible warnings emitted by `parse_url()` in PHP < 5.3.3 when URL parsing failed. Now that the minimum version of PHP required by WordPress is 5.6.20, this is no longer needed. Props netpassprodsr, Howdy_McGee. Fixes #49980. See #24780. Built from https://develop.svn.wordpress.org/trunk@47617 git-svn-id: http://core.svn.wordpress.org/trunk@47392 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
0dc461c72e
commit
ced8fb20a1
|
@ -67,7 +67,7 @@ function redirect_canonical( $requested_url = null, $do_redirect = true ) {
|
|||
$requested_url .= $_SERVER['REQUEST_URI'];
|
||||
}
|
||||
|
||||
$original = @parse_url( $requested_url );
|
||||
$original = parse_url( $requested_url );
|
||||
if ( false === $original ) {
|
||||
return;
|
||||
}
|
||||
|
@ -407,7 +407,7 @@ function redirect_canonical( $requested_url = null, $do_redirect = true ) {
|
|||
$redirect['query'] = preg_replace( '#^\??&*?#', '', $redirect['query'] );
|
||||
if ( $redirect_url && ! empty( $redirect['query'] ) ) {
|
||||
parse_str( $redirect['query'], $_parsed_query );
|
||||
$redirect = @parse_url( $redirect_url );
|
||||
$redirect = parse_url( $redirect_url );
|
||||
|
||||
if ( ! empty( $_parsed_query['name'] ) && ! empty( $redirect['query'] ) ) {
|
||||
parse_str( $redirect['query'], $_parsed_redirect_query );
|
||||
|
@ -425,11 +425,11 @@ function redirect_canonical( $requested_url = null, $do_redirect = true ) {
|
|||
}
|
||||
|
||||
if ( $redirect_url ) {
|
||||
$redirect = @parse_url( $redirect_url );
|
||||
$redirect = parse_url( $redirect_url );
|
||||
}
|
||||
|
||||
// www.example.com vs. example.com
|
||||
$user_home = @parse_url( home_url() );
|
||||
$user_home = parse_url( home_url() );
|
||||
if ( ! empty( $user_home['host'] ) ) {
|
||||
$redirect['host'] = $user_home['host'];
|
||||
}
|
||||
|
@ -637,7 +637,7 @@ function redirect_canonical( $requested_url = null, $do_redirect = true ) {
|
|||
* @return string The altered query string
|
||||
*/
|
||||
function _remove_qs_args_if_not_in_url( $query_string, array $args_to_check, $url ) {
|
||||
$parsed_url = @parse_url( $url );
|
||||
$parsed_url = parse_url( $url );
|
||||
if ( ! empty( $parsed_url['query'] ) ) {
|
||||
parse_str( $parsed_url['query'], $parsed_query );
|
||||
foreach ( $args_to_check as $qv ) {
|
||||
|
@ -660,7 +660,7 @@ function _remove_qs_args_if_not_in_url( $query_string, array $args_to_check, $ur
|
|||
* @return string The altered URL.
|
||||
*/
|
||||
function strip_fragment_from_url( $url ) {
|
||||
$parsed_url = @parse_url( $url );
|
||||
$parsed_url = parse_url( $url );
|
||||
if ( ! empty( $parsed_url['host'] ) ) {
|
||||
// This mirrors code in redirect_canonical(). It does not handle every case.
|
||||
$url = $parsed_url['scheme'] . '://' . $parsed_url['host'];
|
||||
|
|
|
@ -269,7 +269,7 @@ class WP_Http {
|
|||
}
|
||||
}
|
||||
|
||||
$arrURL = @parse_url( $url );
|
||||
$arrURL = parse_url( $url );
|
||||
|
||||
if ( empty( $url ) || empty( $arrURL['scheme'] ) ) {
|
||||
$response = new WP_Error( 'http_request_failed', __( 'A valid URL was not provided.' ) );
|
||||
|
|
|
@ -93,7 +93,7 @@ class WP_Http_Cookie {
|
|||
*/
|
||||
public function __construct( $data, $requested_url = '' ) {
|
||||
if ( $requested_url ) {
|
||||
$arrURL = @parse_url( $requested_url );
|
||||
$arrURL = parse_url( $requested_url );
|
||||
}
|
||||
if ( isset( $arrURL['host'] ) ) {
|
||||
$this->domain = $arrURL['host'];
|
||||
|
|
|
@ -167,11 +167,7 @@ class WP_HTTP_Proxy {
|
|||
* @return bool True, to send through the proxy and false if, the proxy should not be used.
|
||||
*/
|
||||
public function send_through_proxy( $uri ) {
|
||||
/*
|
||||
* parse_url() only handles http, https type URLs, and will emit E_WARNING on failure.
|
||||
* This will be displayed on sites, which is not reasonable.
|
||||
*/
|
||||
$check = @parse_url( $uri );
|
||||
$check = parse_url( $uri );
|
||||
|
||||
// Malformed URL, can not process, but this could mean ssl, so let through anyway.
|
||||
if ( false === $check ) {
|
||||
|
|
|
@ -580,7 +580,9 @@ function wp_set_comment_cookies( $comment, $user, $cookies_consent = true ) {
|
|||
* @param int $seconds Comment cookie lifetime. Default 30000000.
|
||||
*/
|
||||
$comment_cookie_lifetime = time() + apply_filters( 'comment_cookie_lifetime', 30000000 );
|
||||
$secure = ( 'https' === parse_url( home_url(), PHP_URL_SCHEME ) );
|
||||
|
||||
$secure = ( 'https' === parse_url( home_url(), PHP_URL_SCHEME ) );
|
||||
|
||||
setcookie( 'comment_author_' . COOKIEHASH, $comment->comment_author, $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN, $secure );
|
||||
setcookie( 'comment_author_email_' . COOKIEHASH, $comment->comment_author_email, $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN, $secure );
|
||||
setcookie( 'comment_author_url_' . COOKIEHASH, esc_url( $comment->comment_author_url ), $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN, $secure );
|
||||
|
@ -2852,9 +2854,10 @@ function pingback( $content, $post_id ) {
|
|||
foreach ( (array) $post_links_temp as $link_test ) {
|
||||
// If we haven't pung it already and it isn't a link to itself.
|
||||
if ( ! in_array( $link_test, $pung, true ) && ( url_to_postid( $link_test ) != $post->ID )
|
||||
// Also, let's never ping local attachments.
|
||||
&& ! is_local_attachment( $link_test ) ) {
|
||||
$test = @parse_url( $link_test );
|
||||
// Also, let's never ping local attachments.
|
||||
&& ! is_local_attachment( $link_test )
|
||||
) {
|
||||
$test = parse_url( $link_test );
|
||||
if ( $test ) {
|
||||
if ( isset( $test['query'] ) ) {
|
||||
$post_links[] = $link_test;
|
||||
|
|
|
@ -622,7 +622,7 @@ function rss2_site_icon() {
|
|||
* @return string Correct link for the atom:self element.
|
||||
*/
|
||||
function get_self_link() {
|
||||
$host = @parse_url( home_url() );
|
||||
$host = parse_url( home_url() );
|
||||
return set_url_scheme( 'http://' . $host['host'] . wp_unslash( $_SERVER['REQUEST_URI'] ) );
|
||||
}
|
||||
|
||||
|
|
|
@ -866,7 +866,7 @@ function do_enclose( $content = null, $post ) {
|
|||
foreach ( (array) $post_links_temp as $link_test ) {
|
||||
// If we haven't pung it already.
|
||||
if ( ! in_array( $link_test, $pung, true ) ) {
|
||||
$test = @parse_url( $link_test );
|
||||
$test = parse_url( $link_test );
|
||||
if ( false === $test ) {
|
||||
continue;
|
||||
}
|
||||
|
@ -901,7 +901,7 @@ function do_enclose( $content = null, $post ) {
|
|||
$allowed_types = array( 'video', 'audio' );
|
||||
|
||||
// Check to see if we can figure out the mime type from the extension.
|
||||
$url_parts = @parse_url( $url );
|
||||
$url_parts = parse_url( $url );
|
||||
if ( false !== $url_parts ) {
|
||||
$extension = pathinfo( $url_parts['path'], PATHINFO_EXTENSION );
|
||||
if ( ! empty( $extension ) ) {
|
||||
|
@ -1240,7 +1240,7 @@ function add_magic_quotes( $array ) {
|
|||
* @return string|false HTTP content. False on failure.
|
||||
*/
|
||||
function wp_remote_fopen( $uri ) {
|
||||
$parsed_url = @parse_url( $uri );
|
||||
$parsed_url = parse_url( $uri );
|
||||
|
||||
if ( ! $parsed_url || ! is_array( $parsed_url ) ) {
|
||||
return false;
|
||||
|
|
|
@ -522,7 +522,7 @@ function wp_http_validate_url( $url ) {
|
|||
return false;
|
||||
}
|
||||
|
||||
$parsed_url = @parse_url( $url );
|
||||
$parsed_url = parse_url( $url );
|
||||
if ( ! $parsed_url || empty( $parsed_url['host'] ) ) {
|
||||
return false;
|
||||
}
|
||||
|
@ -535,7 +535,7 @@ function wp_http_validate_url( $url ) {
|
|||
return false;
|
||||
}
|
||||
|
||||
$parsed_home = @parse_url( get_option( 'home' ) );
|
||||
$parsed_home = parse_url( get_option( 'home' ) );
|
||||
|
||||
if ( isset( $parsed_home['host'] ) ) {
|
||||
$same_host = strtolower( $parsed_home['host'] ) === strtolower( $parsed_url['host'] );
|
||||
|
@ -654,9 +654,6 @@ function ms_allowed_http_request_hosts( $is_external, $host ) {
|
|||
* in the query are being handled inconsistently. This function works around those
|
||||
* differences as well.
|
||||
*
|
||||
* Error suppression is used as prior to PHP 5.3.3, an E_WARNING would be generated
|
||||
* when URL parsing failed.
|
||||
*
|
||||
* @since 4.4.0
|
||||
* @since 4.7.0 The `$component` parameter was added for parity with PHP's `parse_url()`.
|
||||
*
|
||||
|
@ -684,7 +681,7 @@ function wp_parse_url( $url, $component = -1 ) {
|
|||
$url = 'placeholder://placeholder' . $url;
|
||||
}
|
||||
|
||||
$parts = @parse_url( $url );
|
||||
$parts = parse_url( $url );
|
||||
|
||||
if ( false === $parts ) {
|
||||
// Parsing failure.
|
||||
|
|
|
@ -1423,8 +1423,7 @@ if ( ! function_exists( 'wp_validate_redirect' ) ) :
|
|||
$cut = strpos( $location, '?' );
|
||||
$test = $cut ? substr( $location, 0, $cut ) : $location;
|
||||
|
||||
// @-operator is used to prevent possible warnings in PHP < 5.3.3.
|
||||
$lp = @parse_url( $test );
|
||||
$lp = parse_url( $test );
|
||||
|
||||
// Give up if malformed URL.
|
||||
if ( false === $lp ) {
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '5.5-alpha-47616';
|
||||
$wp_version = '5.5-alpha-47617';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue