Skip to content

Commit 40eb288

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 fad899e commit 40eb288

File tree

4 files changed

+9
-14
lines changed

4 files changed

+9
-14
lines changed

NEWS

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

406407
- Date:
407408
. Added DateTime[Immutable]::createFromTimestamp. (Marc Bennewitz)

UPGRADING

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

931931
- Curl:
932932
. The Curl extension now requires at least libcurl 7.61.0.
933+
. The CURLOPT_DNS_USE_GLOBAL_CACHE Curl option no longer has any
934+
effect, and is silently ignored. This underlying feature was
935+
deprecated in libcurl 7.11.1 and removed in 7.62.0.
933936

934937
- Date:
935938
. The class constants are typed now.

ext/curl/interface.c

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1165,9 +1165,6 @@ static void _php_curl_set_default_options(php_curl *ch)
11651165
curl_easy_setopt(ch->cp, CURLOPT_INFILE, (void *) ch);
11661166
curl_easy_setopt(ch->cp, CURLOPT_HEADERFUNCTION, curl_write_header);
11671167
curl_easy_setopt(ch->cp, CURLOPT_WRITEHEADER, (void *) ch);
1168-
#ifndef ZTS
1169-
curl_easy_setopt(ch->cp, CURLOPT_DNS_USE_GLOBAL_CACHE, 1);
1170-
#endif
11711168
curl_easy_setopt(ch->cp, CURLOPT_DNS_CACHE_TIMEOUT, 120);
11721169
curl_easy_setopt(ch->cp, CURLOPT_MAXREDIRS, 20); /* prevent infinite redirects */
11731170

@@ -1657,7 +1654,6 @@ static zend_result _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue
16571654
case CURLOPT_COOKIESESSION:
16581655
case CURLOPT_CRLF:
16591656
case CURLOPT_DNS_CACHE_TIMEOUT:
1660-
case CURLOPT_DNS_USE_GLOBAL_CACHE:
16611657
case CURLOPT_FAILONERROR:
16621658
case CURLOPT_FILETIME:
16631659
case CURLOPT_FORBID_REUSE:
@@ -1806,12 +1802,6 @@ static zend_result _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue
18061802
php_error_docref(NULL, E_WARNING, "CURLPROTO_FILE cannot be activated when an open_basedir is set");
18071803
return FAILURE;
18081804
}
1809-
# if defined(ZTS)
1810-
if (option == CURLOPT_DNS_USE_GLOBAL_CACHE && lval) {
1811-
php_error_docref(NULL, E_WARNING, "CURLOPT_DNS_USE_GLOBAL_CACHE cannot be activated when thread safety is enabled");
1812-
return FAILURE;
1813-
}
1814-
# endif
18151805
error = curl_easy_setopt(ch->cp, option, lval);
18161806
break;
18171807
case CURLOPT_SAFE_UPLOAD:
@@ -2146,6 +2136,7 @@ static zend_result _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue
21462136
}
21472137

21482138
case CURLOPT_BINARYTRANSFER:
2139+
case CURLOPT_DNS_USE_GLOBAL_CACHE:
21492140
/* Do nothing, just backward compatibility */
21502141
break;
21512142

ext/curl/tests/bug71144.phpt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
--TEST--
22
Bug #71144 (Sementation fault when using cURL with ZTS)
3+
--DESCRIPTION--
4+
Since Curl 7.62, CURLOPT_DNS_USE_GLOBAL_CACHE has no effect, and is
5+
silently ignored.
36
--EXTENSIONS--
47
curl
5-
--SKIPIF--
6-
<?php if (!PHP_ZTS) { print "skip only for zts build"; } ?>
78
--FILE--
89
<?php
910
$ch = curl_init();
1011
var_dump(curl_setopt($ch, CURLOPT_DNS_USE_GLOBAL_CACHE, 1));
1112
?>
1213
--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)
14+
bool(true)

0 commit comments

Comments
 (0)