Skip to content

Commit 6b73e69

Browse files
phansysnikic
authored andcommitted
Add more missing CURL_VERSION_* constants
And also check for CURL_VERSION_* constants in the sync-constants.php script. Related to request #72189: Add missing `CURL_VERSION_*` constants.
1 parent d91b643 commit 6b73e69

4 files changed

Lines changed: 65 additions & 11 deletions

File tree

UPGRADING

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -622,9 +622,11 @@ Curl:
622622
. CURL_SSLVERSION_MAX_TLSv1_2
623623
. CURL_SSLVERSION_MAX_TLSv1_3
624624
. CURL_SSLVERSION_TLSv1_3
625+
. CURL_VERSION_ALTSVC
625626
. CURL_VERSION_ASYNCHDNS
626627
. CURL_VERSION_BROTLI
627628
. CURL_VERSION_CONV
629+
. CURL_VERSION_CURLDEBUG
628630
. CURL_VERSION_DEBUG
629631
. CURL_VERSION_GSSAPI
630632
. CURL_VERSION_GSSNEGOTIATE
@@ -634,6 +636,7 @@ Curl:
634636
. CURL_VERSION_MULTI_SSL
635637
. CURL_VERSION_NTLM
636638
. CURL_VERSION_NTLM_WB
639+
. CURL_VERSION_PSL
637640
. CURL_VERSION_SPNEGO
638641
. CURL_VERSION_SSPI
639642
. CURL_VERSION_TLSAUTH_SRP
@@ -729,7 +732,7 @@ LDAP:
729732

730733
- mbstring.regex_stack_limit
731734
. New INI directive (since 7.3.6) limiting stack depth of mbstring/oniguruma
732-
regular expressions.
735+
regular expressions.
733736

734737
========================================
735738
12. Windows Support
@@ -748,4 +751,3 @@ LDAP:
748751

749752
. The cyclic GC has been enhanced, which may result in considerable performance
750753
improvements.
751-

ext/curl/interface.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1130,6 +1130,7 @@ PHP_MINIT_FUNCTION(curl)
11301130
#endif
11311131

11321132
#if LIBCURL_VERSION_NUM >= 0x071306 /* Available since 7.19.6 */
1133+
REGISTER_CURL_CONSTANT(CURL_VERSION_CURLDEBUG);
11331134
REGISTER_CURL_CONSTANT(CURLOPT_SSH_KNOWNHOSTS);
11341135
#endif
11351136

@@ -1334,6 +1335,7 @@ PHP_MINIT_FUNCTION(curl)
13341335

13351336
#if LIBCURL_VERSION_NUM >= 0x072f00 /* Available since 7.47.0 */
13361337
REGISTER_CURL_CONSTANT(CURL_HTTP_VERSION_2TLS);
1338+
REGISTER_CURL_CONSTANT(CURL_VERSION_PSL);
13371339
#endif
13381340

13391341
#if LIBCURL_VERSION_NUM >= 0x073000 /* Available since 7.48.0 */
@@ -1452,6 +1454,10 @@ PHP_MINIT_FUNCTION(curl)
14521454
REGISTER_CURL_CONSTANT(CURLOPT_TLS13_CIPHERS);
14531455
#endif
14541456

1457+
#if LIBCURL_VERSION_NUM >= 0x074001 /* Available since 7.64.1 */
1458+
REGISTER_CURL_CONSTANT(CURL_VERSION_ALTSVC);
1459+
#endif
1460+
14551461
REGISTER_CURL_CONSTANT(CURLOPT_SAFE_UPLOAD);
14561462

14571463
#ifdef PHP_CURL_NEED_OPENSSL_TSL

ext/curl/sync-constants.php

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
'CURLOPT_PROGRESSDATA'
1818
];
1919

20+
const CONSTANTS_REGEX_PATTERN = '~^CURL(?:OPT|_VERSION)_[A-Z0-9_]+$~';
21+
2022
$curlConstants = getCurlConstants();
2123
$sourceConstants = getSourceConstants();
2224

@@ -157,13 +159,8 @@ function getCurlConstants() : array
157159
$deprecated = $match[3] ?? null;
158160
$removed = $match[4] ?? null;
159161

160-
if (strpos($name, 'CURLOPT_') !== 0) {
161-
// not a CURLOPT_* constant
162-
continue;
163-
}
164-
165-
if (in_array($name, IGNORED_CONSTANTS)) {
166-
// purposefully ignored constant
162+
if (in_array($name, IGNORED_CONSTANTS, true) || !preg_match(CONSTANTS_REGEX_PATTERN, $name)) {
163+
// not a wanted constant
167164
continue;
168165
}
169166

@@ -197,8 +194,8 @@ function getSourceConstants() : array
197194
continue;
198195
}
199196

200-
if (strpos($name, 'CURLOPT_') !== 0) {
201-
// not a CURLOPT_* constant
197+
if (!preg_match(CONSTANTS_REGEX_PATTERN, $name)) {
198+
// not a wanted constant
202199
continue;
203200
}
204201

ext/curl/tests/bug72189.phpt

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
--TEST--
2+
Request #72189 (Add missing CURL_VERSION_* constants)
3+
--SKIPIF--
4+
<?php
5+
6+
include 'skipif.inc';
7+
8+
$version = curl_version();
9+
10+
if ($version['version_number'] < 0x071306) {
11+
exit('skip: test works only with curl >= 7.19.6');
12+
}
13+
14+
?>
15+
--FILE--
16+
<?php
17+
18+
$version = curl_version();
19+
20+
$bitfields = [
21+
CURL_VERSION_ASYNCHDNS,
22+
CURL_VERSION_CONV,
23+
CURL_VERSION_CURLDEBUG,
24+
CURL_VERSION_DEBUG,
25+
CURL_VERSION_GSSNEGOTIATE,
26+
CURL_VERSION_IDN,
27+
CURL_VERSION_IPV6,
28+
CURL_VERSION_KERBEROS4,
29+
CURL_VERSION_LARGEFILE,
30+
CURL_VERSION_LIBZ,
31+
CURL_VERSION_NTLM,
32+
CURL_VERSION_SPNEGO,
33+
CURL_VERSION_SSL,
34+
CURL_VERSION_SSPI,
35+
];
36+
37+
$matchesCount = 0;
38+
39+
foreach ($bitfields as $feature) {
40+
if ($version['features'] & $feature) {
41+
++$matchesCount;
42+
}
43+
}
44+
45+
var_dump($matchesCount > 0);
46+
47+
?>
48+
--EXPECT--
49+
bool(true)

0 commit comments

Comments
 (0)