Make WordPress Core


Ignore:
Timestamp:
07/18/2026 11:15:42 PM (3 months ago)
Author:
SergeyBiryukov
Message:

Tests: Use wp_parse_url() in plugin management REST API endpoint tests.

This resolves a warning in preparation for updating to WPCS 3.4.0:

Silencing errors is strongly discouraged. Use proper error checking instead.

Additionally, this brings consistency with a similar fragment in the pattern directory endpoint tests, which already used wp_parse_url().

Follow-up to [48242], [51021].

See #64894.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/rest-api/rest-block-directory-controller.php

    r56559 r62795  
    274274                        'pre_http_request',
    275275                        static function ( $response, $parsed_args, $url ) use ( $blocked_host ) {
    276                                 if ( @parse_url( $url, PHP_URL_HOST ) === $blocked_host ) {
     276                                if ( wp_parse_url( $url, PHP_URL_HOST ) === $blocked_host ) {
    277277                                        return new WP_Error( 'plugins_api_failed', "An expected error occurred connecting to $blocked_host because of a unit test", "cURL error 7: Failed to connect to $blocked_host port 80: Connection refused" );
    278278
Note: See TracChangeset for help on using the changeset viewer.