Make WordPress Core

Changeset 47617


Ignore:
Timestamp:
04/24/2020 07:26:57 AM (6 years ago)
Author:
SergeyBiryukov
Message:

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.

Location:
trunk/src/wp-includes
Files:
9 edited

Legend:

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

    r47550 r47617  
    6868        }
    6969
    70         $original = @parse_url( $requested_url );
     70        $original = parse_url( $requested_url );
    7171        if ( false === $original ) {
    7272                return;
     
    408408        if ( $redirect_url && ! empty( $redirect['query'] ) ) {
    409409                parse_str( $redirect['query'], $_parsed_query );
    410                 $redirect = @parse_url( $redirect_url );
     410                $redirect = parse_url( $redirect_url );
    411411
    412412                if ( ! empty( $_parsed_query['name'] ) && ! empty( $redirect['query'] ) ) {
     
    426426
    427427        if ( $redirect_url ) {
    428                 $redirect = @parse_url( $redirect_url );
     428                $redirect = parse_url( $redirect_url );
    429429        }
    430430
    431431        // www.example.com vs. example.com
    432         $user_home = @parse_url( home_url() );
     432        $user_home = parse_url( home_url() );
    433433        if ( ! empty( $user_home['host'] ) ) {
    434434                $redirect['host'] = $user_home['host'];
     
    638638 */
    639639function _remove_qs_args_if_not_in_url( $query_string, array $args_to_check, $url ) {
    640         $parsed_url = @parse_url( $url );
     640        $parsed_url = parse_url( $url );
    641641        if ( ! empty( $parsed_url['query'] ) ) {
    642642                parse_str( $parsed_url['query'], $parsed_query );
     
    661661 */
    662662function strip_fragment_from_url( $url ) {
    663         $parsed_url = @parse_url( $url );
     663        $parsed_url = parse_url( $url );
    664664        if ( ! empty( $parsed_url['host'] ) ) {
    665665                // This mirrors code in redirect_canonical(). It does not handle every case.
  • trunk/src/wp-includes/class-http.php

    r47557 r47617  
    270270                }
    271271
    272                 $arrURL = @parse_url( $url );
     272                $arrURL = parse_url( $url );
    273273
    274274                if ( empty( $url ) || empty( $arrURL['scheme'] ) ) {
  • trunk/src/wp-includes/class-wp-http-cookie.php

    r47557 r47617  
    9494        public function __construct( $data, $requested_url = '' ) {
    9595                if ( $requested_url ) {
    96                         $arrURL = @parse_url( $requested_url );
     96                        $arrURL = parse_url( $requested_url );
    9797                }
    9898                if ( isset( $arrURL['host'] ) ) {
  • trunk/src/wp-includes/class-wp-http-proxy.php

    r47508 r47617  
    168168         */
    169169        public function send_through_proxy( $uri ) {
    170                 /*
    171                  * parse_url() only handles http, https type URLs, and will emit E_WARNING on failure.
    172                  * This will be displayed on sites, which is not reasonable.
    173                  */
    174                 $check = @parse_url( $uri );
     170                $check = parse_url( $uri );
    175171
    176172                // Malformed URL, can not process, but this could mean ssl, so let through anyway.
  • trunk/src/wp-includes/comment.php

    r47611 r47617  
    581581         */
    582582        $comment_cookie_lifetime = time() + apply_filters( 'comment_cookie_lifetime', 30000000 );
    583         $secure                  = ( 'https' === parse_url( home_url(), PHP_URL_SCHEME ) );
     583
     584        $secure = ( 'https' === parse_url( home_url(), PHP_URL_SCHEME ) );
     585
    584586        setcookie( 'comment_author_' . COOKIEHASH, $comment->comment_author, $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN, $secure );
    585587        setcookie( 'comment_author_email_' . COOKIEHASH, $comment->comment_author_email, $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN, $secure );
     
    28532855                // If we haven't pung it already and it isn't a link to itself.
    28542856                if ( ! in_array( $link_test, $pung, true ) && ( url_to_postid( $link_test ) != $post->ID )
    2855                                 // Also, let's never ping local attachments.
    2856                                 && ! is_local_attachment( $link_test ) ) {
    2857                         $test = @parse_url( $link_test );
     2857                        // Also, let's never ping local attachments.
     2858                        && ! is_local_attachment( $link_test )
     2859                ) {
     2860                        $test = parse_url( $link_test );
    28582861                        if ( $test ) {
    28592862                                if ( isset( $test['query'] ) ) {
  • trunk/src/wp-includes/feed.php

    r47397 r47617  
    623623 */
    624624function get_self_link() {
    625         $host = @parse_url( home_url() );
     625        $host = parse_url( home_url() );
    626626        return set_url_scheme( 'http://' . $host['host'] . wp_unslash( $_SERVER['REQUEST_URI'] ) );
    627627}
  • trunk/src/wp-includes/functions.php

    r47550 r47617  
    867867                // If we haven't pung it already.
    868868                if ( ! in_array( $link_test, $pung, true ) ) {
    869                         $test = @parse_url( $link_test );
     869                        $test = parse_url( $link_test );
    870870                        if ( false === $test ) {
    871871                                continue;
     
    902902
    903903                                // Check to see if we can figure out the mime type from the extension.
    904                                 $url_parts = @parse_url( $url );
     904                                $url_parts = parse_url( $url );
    905905                                if ( false !== $url_parts ) {
    906906                                        $extension = pathinfo( $url_parts['path'], PATHINFO_EXTENSION );
     
    12411241 */
    12421242function wp_remote_fopen( $uri ) {
    1243         $parsed_url = @parse_url( $uri );
     1243        $parsed_url = parse_url( $uri );
    12441244
    12451245        if ( ! $parsed_url || ! is_array( $parsed_url ) ) {
  • trunk/src/wp-includes/http.php

    r47550 r47617  
    523523        }
    524524
    525         $parsed_url = @parse_url( $url );
     525        $parsed_url = parse_url( $url );
    526526        if ( ! $parsed_url || empty( $parsed_url['host'] ) ) {
    527527                return false;
     
    536536        }
    537537
    538         $parsed_home = @parse_url( get_option( 'home' ) );
     538        $parsed_home = parse_url( get_option( 'home' ) );
    539539
    540540        if ( isset( $parsed_home['host'] ) ) {
     
    655655 * differences as well.
    656656 *
    657  * Error suppression is used as prior to PHP 5.3.3, an E_WARNING would be generated
    658  * when URL parsing failed.
    659  *
    660657 * @since 4.4.0
    661658 * @since 4.7.0 The `$component` parameter was added for parity with PHP's `parse_url()`.
     
    685682        }
    686683
    687         $parts = @parse_url( $url );
     684        $parts = parse_url( $url );
    688685
    689686        if ( false === $parts ) {
  • trunk/src/wp-includes/pluggable.php

    r47554 r47617  
    14241424                $test = $cut ? substr( $location, 0, $cut ) : $location;
    14251425
    1426                 // @-operator is used to prevent possible warnings in PHP < 5.3.3.
    1427                 $lp = @parse_url( $test );
     1426                $lp = parse_url( $test );
    14281427
    14291428                // Give up if malformed URL.
Note: See TracChangeset for help on using the changeset viewer.