Make WordPress Core

Ticket #63547: 63547.patch

File 63547.patch, 3.6 KB (added by pmbaldha, 7 months ago)

Created patch file https://github.com/WordPress/Requests/pull/932 for easy testing

  • src/wp-includes/Requests/src/Transport/Curl.php

    diff --git a/src/wp-includes/Requests/src/Transport/Curl.php b/src/wp-includes/Requests/src/Transport/Curl.php
    index 7316987b5f..da8f53e0e2 100644
    a b final class Curl implements Transport { 
    418418                                }
    419419                }
    420420
    421                 // cURL requires a minimum timeout of 1 second when using the system
    422                 // DNS resolver, as it uses `alarm()`, which is second resolution only.
    423                 // There's no way to detect which DNS resolver is being used from our
    424                 // end, so we need to round up regardless of the supplied timeout.
    425                 //
    426                 // https://github.com/curl/curl/blob/4f45240bc84a9aa648c8f7243be7b79e9f9323a5/lib/hostip.c#L606-L609
    427                 $timeout = max($options['timeout'], 1);
     421                $using_asynch_dns = false;
     422                if (defined('CURL_VERSION_ASYNCHDNS')) {
     423                        $curl_version = curl_version();
     424                        // phpcs:ignore PHPCompatibility.Constants.NewConstants.curl_version_asynchdnsFound
     425                        if (CURL_VERSION_ASYNCHDNS & $curl_version['features']) {
     426                                $using_asynch_dns = true;
     427                        }
     428                }
     429
     430                if ($using_asynch_dns) {
     431                        // It should be safe to use any timeout, even if less than 1 second.
     432                        $timeout = $options['timeout'];
     433                } else {
     434                        // cURL requires a minimum timeout of 1 second when using the system
     435                        // DNS resolver, as it uses `alarm()`, which is second resolution only.
     436                        // There's no way to detect which DNS resolver is being used from our
     437                        // end, so we need to round up regardless of the supplied timeout.
     438                        //
     439                        // https://github.com/curl/curl/blob/4f45240bc84a9aa648c8f7243be7b79e9f9323a5/lib/hostip.c#L606-L609
     440                        $timeout = max($options['timeout'], 1);
     441                }
    428442
    429443                if (is_int($timeout) || $this->version < self::CURL_7_16_2) {
    430444                        curl_setopt($this->handle, CURLOPT_TIMEOUT, ceil($timeout));