Skip to content

Commit dfd1cd0

Browse files
committed
ext/curl: No-op CURLOPT_DNS_USE_GLOBAL_CACHE constant
Libcurl `CURLOPT_DNS_USE_GLOBAL_CACHE` constant is no longer supported since libcurl[^1] 7.62. This no-ops the constant, but without causing any deprecation notices. [^1]: [CURLOPT_DNS_USE_GLOBAL_CACHE](https://curl.se/libcurl/c/CURLOPT_DNS_USE_GLOBAL_CACHE.html)
1 parent 7fd54f9 commit dfd1cd0

File tree

6 files changed

+11
-18
lines changed

6 files changed

+11
-18
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ PHP NEWS
144144
. Deprecated the CURLOPT_BINARYTRANSFER constant. (divinity76)
145145
. Bumped required libcurl version to 7.61.0. (Ayesh)
146146
. Added feature_list key to the curl_version() return value. (Ayesh)
147+
. The CURLOPT_DNS_USE_GLOBAL_CACHE option is now silently ignored. (Ayesh Karunaratne)
147148

148149
- Date:
149150
. Added DateTime[Immutable]::createFromTimestamp. (Marc Bennewitz)

UPGRADING

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -734,6 +734,9 @@ PHP 8.4 UPGRADE NOTES
734734

735735
- Curl:
736736
. The Curl extension now requires at least libcurl 7.61.0.
737+
. The CURLOPT_DNS_USE_GLOBAL_CACHE Curl option no longer has any
738+
effect, and is silently ignored. This underlying feature was
739+
deprecated in libcurl 7.11.1 and removed in 7.62.0.
737740

738741
- Date:
739742
. The class constants are typed now.

ext/curl/curl.stub.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,8 @@
7474
const CURLOPT_DNS_CACHE_TIMEOUT = UNKNOWN;
7575
/**
7676
* @var int
77-
* @cvalue CURLOPT_DNS_USE_GLOBAL_CACHE
7877
*/
79-
const CURLOPT_DNS_USE_GLOBAL_CACHE = UNKNOWN;
78+
const CURLOPT_DNS_USE_GLOBAL_CACHE = -1;
8079
/**
8180
* @var int
8281
* @cvalue CURLOPT_EGDSOCKET

ext/curl/curl_arginfo.h

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ext/curl/interface.c

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,9 +1103,6 @@ static void _php_curl_set_default_options(php_curl *ch)
11031103
curl_easy_setopt(ch->cp, CURLOPT_INFILE, (void *) ch);
11041104
curl_easy_setopt(ch->cp, CURLOPT_HEADERFUNCTION, curl_write_header);
11051105
curl_easy_setopt(ch->cp, CURLOPT_WRITEHEADER, (void *) ch);
1106-
#ifndef ZTS
1107-
curl_easy_setopt(ch->cp, CURLOPT_DNS_USE_GLOBAL_CACHE, 1);
1108-
#endif
11091106
curl_easy_setopt(ch->cp, CURLOPT_DNS_CACHE_TIMEOUT, 120);
11101107
curl_easy_setopt(ch->cp, CURLOPT_MAXREDIRS, 20); /* prevent infinite redirects */
11111108

@@ -1589,7 +1586,6 @@ static zend_result _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue
15891586
case CURLOPT_COOKIESESSION:
15901587
case CURLOPT_CRLF:
15911588
case CURLOPT_DNS_CACHE_TIMEOUT:
1592-
case CURLOPT_DNS_USE_GLOBAL_CACHE:
15931589
case CURLOPT_FAILONERROR:
15941590
case CURLOPT_FILETIME:
15951591
case CURLOPT_FORBID_REUSE:
@@ -1735,12 +1731,6 @@ static zend_result _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue
17351731
php_error_docref(NULL, E_WARNING, "CURLPROTO_FILE cannot be activated when an open_basedir is set");
17361732
return FAILURE;
17371733
}
1738-
# if defined(ZTS)
1739-
if (option == CURLOPT_DNS_USE_GLOBAL_CACHE && lval) {
1740-
php_error_docref(NULL, E_WARNING, "CURLOPT_DNS_USE_GLOBAL_CACHE cannot be activated when thread safety is enabled");
1741-
return FAILURE;
1742-
}
1743-
# endif
17441734
error = curl_easy_setopt(ch->cp, option, lval);
17451735
break;
17461736
case CURLOPT_SAFE_UPLOAD:
@@ -2075,6 +2065,7 @@ static zend_result _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue
20752065
}
20762066

20772067
case CURLOPT_BINARYTRANSFER:
2068+
case CURLOPT_DNS_USE_GLOBAL_CACHE:
20782069
/* Do nothing, just backward compatibility */
20792070
break;
20802071

ext/curl/tests/bug71144.phpt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
--TEST--
22
Bug #71144 (Sementation fault when using cURL with ZTS)
3+
Since Curl 7.62, CURLOPT_DNS_USE_GLOBAL_CACHE has no effect, and is
4+
silently ignored.
35
--EXTENSIONS--
46
curl
5-
--SKIPIF--
6-
<?php if (!PHP_ZTS) { print "skip only for zts build"; } ?>
77
--FILE--
88
<?php
99
$ch = curl_init();
1010
var_dump(curl_setopt($ch, CURLOPT_DNS_USE_GLOBAL_CACHE, 1));
1111
?>
1212
--EXPECTF--
13-
Warning: curl_setopt(): CURLOPT_DNS_USE_GLOBAL_CACHE cannot be activated when thread safety is enabled in %sbug71144.php on line %d
14-
bool(false)
13+
bool(true)

0 commit comments

Comments
 (0)