Skip to content

Commit 47ccc3b

Browse files
Merge branch 'php:master' into exif_heif
2 parents 25308f6 + ba0f9fb commit 47ccc3b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1754
-386
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ PHP NEWS
1818
- Curl:
1919
. Deprecated the CURLOPT_BINARYTRANSFER constant. (divinity76)
2020
. Bumped required libcurl version to 7.61.0. (Ayesh)
21+
. Added feature_list key to the curl_version() return value (Ayesh)
2122

2223
- Date:
2324
. Added DateTime[Immutable]::createFromTimestamp. (Marc Bennewitz)

UPGRADING

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

253253
- Curl:
254254
. The CURLOPT_BINARYTRANSFER constant is deprecated.
255+
. curl_version() returns an additional feature_list value, which is an
256+
associative array of all known Curl features, and whether they are
257+
supported (true) or not (false).
255258

256259
- Date:
257260
. Calling DatePeriod::__construct(string $isostr, int $options = 0) is

Zend/Optimizer/zend_func_infos.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -517,9 +517,7 @@ static const func_info_t func_infos[] = {
517517
F1("sha1", MAY_BE_STRING),
518518
F1("sha1_file", MAY_BE_STRING|MAY_BE_FALSE),
519519
F1("inet_ntop", MAY_BE_STRING|MAY_BE_FALSE),
520-
#if defined(HAVE_INET_PTON)
521520
F1("inet_pton", MAY_BE_STRING|MAY_BE_FALSE),
522-
#endif
523521
F1("metaphone", MAY_BE_STRING),
524522
F1("headers_list", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_STRING),
525523
F1("htmlspecialchars", MAY_BE_STRING),

Zend/zend.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,6 +1183,8 @@ void zend_shutdown(void) /* {{{ */
11831183
#endif
11841184
zend_destroy_rsrc_list_dtors();
11851185

1186+
zend_unload_modules();
1187+
11861188
zend_optimizer_shutdown();
11871189
startup_done = false;
11881190
}

Zend/zend.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,7 @@ void zend_shutdown(void);
279279
void zend_register_standard_ini_entries(void);
280280
zend_result zend_post_startup(void);
281281
void zend_set_utility_values(zend_utility_values *utility_values);
282+
void zend_unload_modules(void);
282283

283284
ZEND_API ZEND_COLD ZEND_NORETURN void _zend_bailout(const char *filename, uint32_t lineno);
284285
ZEND_API size_t zend_get_page_size(void);

Zend/zend_API.c

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ ZEND_API HashTable module_registry;
4141
static zend_module_entry **module_request_startup_handlers;
4242
static zend_module_entry **module_request_shutdown_handlers;
4343
static zend_module_entry **module_post_deactivate_handlers;
44+
static zend_module_entry **modules_dl_loaded;
4445

4546
static zend_class_entry **class_cleanup_handlers;
4647

@@ -2398,6 +2399,7 @@ ZEND_API void zend_collect_module_handlers(void) /* {{{ */
23982399
int startup_count = 0;
23992400
int shutdown_count = 0;
24002401
int post_deactivate_count = 0;
2402+
int dl_loaded_count = 0;
24012403
zend_class_entry *ce;
24022404
int class_count = 0;
24032405

@@ -2412,6 +2414,9 @@ ZEND_API void zend_collect_module_handlers(void) /* {{{ */
24122414
if (module->post_deactivate_func) {
24132415
post_deactivate_count++;
24142416
}
2417+
if (module->handle) {
2418+
dl_loaded_count++;
2419+
}
24152420
} ZEND_HASH_FOREACH_END();
24162421
module_request_startup_handlers = (zend_module_entry**)realloc(
24172422
module_request_startup_handlers,
@@ -2424,6 +2429,9 @@ ZEND_API void zend_collect_module_handlers(void) /* {{{ */
24242429
module_request_shutdown_handlers[shutdown_count] = NULL;
24252430
module_post_deactivate_handlers = module_request_shutdown_handlers + shutdown_count + 1;
24262431
module_post_deactivate_handlers[post_deactivate_count] = NULL;
2432+
/* Cannot reuse module_request_startup_handlers because it is freed in zend_destroy_modules, which happens before zend_unload_modules. */
2433+
modules_dl_loaded = realloc(modules_dl_loaded, sizeof(zend_module_entry*) * (dl_loaded_count + 1));
2434+
modules_dl_loaded[dl_loaded_count] = NULL;
24272435
startup_count = 0;
24282436

24292437
ZEND_HASH_MAP_FOREACH_PTR(&module_registry, module) {
@@ -2436,6 +2444,9 @@ ZEND_API void zend_collect_module_handlers(void) /* {{{ */
24362444
if (module->post_deactivate_func) {
24372445
module_post_deactivate_handlers[--post_deactivate_count] = module;
24382446
}
2447+
if (module->handle) {
2448+
modules_dl_loaded[--dl_loaded_count] = module;
2449+
}
24392450
} ZEND_HASH_FOREACH_END();
24402451

24412452
/* Collect internal classes with static members */
@@ -3238,18 +3249,23 @@ void module_destructor(zend_module_entry *module) /* {{{ */
32383249
clean_module_functions(module);
32393250
}
32403251

3241-
#if HAVE_LIBDL
3242-
if (module->handle && !getenv("ZEND_DONT_UNLOAD_MODULES")) {
3243-
DL_UNLOAD(module->handle);
3244-
}
3245-
#endif
3246-
32473252
#if ZEND_RC_DEBUG
32483253
zend_rc_debug = orig_rc_debug;
32493254
#endif
32503255
}
32513256
/* }}} */
32523257

3258+
void module_registry_unload(const zend_module_entry *module)
3259+
{
3260+
#if HAVE_LIBDL
3261+
if (!getenv("ZEND_DONT_UNLOAD_MODULES")) {
3262+
DL_UNLOAD(module->handle);
3263+
}
3264+
#else
3265+
ZEND_IGNORE_VALUE(module);
3266+
#endif
3267+
}
3268+
32533269
ZEND_API void zend_activate_modules(void) /* {{{ */
32543270
{
32553271
zend_module_entry **p = module_request_startup_handlers;
@@ -3294,6 +3310,18 @@ ZEND_API void zend_deactivate_modules(void) /* {{{ */
32943310
}
32953311
/* }}} */
32963312

3313+
void zend_unload_modules(void) /* {{{ */
3314+
{
3315+
zend_module_entry **modules = modules_dl_loaded;
3316+
while (*modules) {
3317+
module_registry_unload(*modules);
3318+
modules++;
3319+
}
3320+
free(modules_dl_loaded);
3321+
modules_dl_loaded = NULL;
3322+
}
3323+
/* }}} */
3324+
32973325
ZEND_API void zend_post_deactivate_modules(void) /* {{{ */
32983326
{
32993327
if (EG(full_tables_cleanup)) {
@@ -3312,6 +3340,9 @@ ZEND_API void zend_post_deactivate_modules(void) /* {{{ */
33123340
break;
33133341
}
33143342
module_destructor(module);
3343+
if (module->handle) {
3344+
module_registry_unload(module);
3345+
}
33153346
zend_string_release_ex(key, 0);
33163347
} ZEND_HASH_MAP_FOREACH_END_DEL();
33173348
} else {

Zend/zend_modules.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ extern ZEND_API HashTable module_registry;
125125

126126
void module_destructor(zend_module_entry *module);
127127
int module_registry_request_startup(zend_module_entry *module);
128-
int module_registry_unload_temp(const zend_module_entry *module);
128+
void module_registry_unload(const zend_module_entry *module);
129129
END_EXTERN_C()
130130

131131
#endif

build/config.guess

100644100755
File mode changed.

build/config.sub

100644100755
File mode changed.

configure.ac

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,6 @@ dnl ----------------------------------------------------------------------------
383383

384384
dnl QNX requires unix.h to allow functions in libunix to work properly.
385385
AC_CHECK_HEADERS([ \
386-
stdint.h \
387386
dirent.h \
388387
sys/param.h \
389388
sys/types.h \
@@ -398,7 +397,6 @@ grp.h \
398397
ieeefp.h \
399398
langinfo.h \
400399
linux/sock_diag.h \
401-
malloc.h \
402400
os/signpost.h \
403401
poll.h \
404402
pty.h \
@@ -603,7 +601,6 @@ getgrnam_r \
603601
getpwuid_r \
604602
getwd \
605603
glob \
606-
inet_pton \
607604
localtime_r \
608605
lchown \
609606
memcntl \
@@ -640,10 +637,8 @@ memrchr \
640637
mempcpy \
641638
)
642639

643-
AC_CHECK_FUNC(inet_ntop,[],[
644-
AC_MSG_ERROR([Cannot find inet_ntop which is required])
645-
]
646-
)
640+
AC_CHECK_FUNC([inet_ntop],,[AC_MSG_ERROR([Required inet_ntop not found.])])
641+
AC_CHECK_FUNC([inet_pton],,[AC_MSG_ERROR([Required inet_pton not found.])])
647642

648643
dnl Check for strerror_r, and if its a POSIX-compatible or a GNU specific version.
649644
AC_FUNC_STRERROR_R

ext/curl/interface.c

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ PHP_MINFO_FUNCTION(curl)
261261
php_info_print_table_row(2, "Age", str);
262262

263263
/* To update on each new cURL release using src/main.c in cURL sources */
264+
/* make sure to sync this list with curl_version as well */
264265
if (d->features) {
265266
struct feat {
266267
const char *name;
@@ -1000,6 +1001,68 @@ PHP_FUNCTION(curl_version)
10001001
CAAL("version_number", d->version_num);
10011002
CAAL("age", d->age);
10021003
CAAL("features", d->features);
1004+
/* Add an array of features */
1005+
{
1006+
struct feat {
1007+
const char *name;
1008+
int bitmask;
1009+
};
1010+
1011+
unsigned int i;
1012+
zval feature_list;
1013+
array_init(&feature_list);
1014+
1015+
/* Sync this list with PHP_MINFO_FUNCTION(curl) as well */
1016+
static const struct feat feats[] = {
1017+
{"AsynchDNS", CURL_VERSION_ASYNCHDNS},
1018+
{"CharConv", CURL_VERSION_CONV},
1019+
{"Debug", CURL_VERSION_DEBUG},
1020+
{"GSS-Negotiate", CURL_VERSION_GSSNEGOTIATE},
1021+
{"IDN", CURL_VERSION_IDN},
1022+
{"IPv6", CURL_VERSION_IPV6},
1023+
{"krb4", CURL_VERSION_KERBEROS4},
1024+
{"Largefile", CURL_VERSION_LARGEFILE},
1025+
{"libz", CURL_VERSION_LIBZ},
1026+
{"NTLM", CURL_VERSION_NTLM},
1027+
{"NTLMWB", CURL_VERSION_NTLM_WB},
1028+
{"SPNEGO", CURL_VERSION_SPNEGO},
1029+
{"SSL", CURL_VERSION_SSL},
1030+
{"SSPI", CURL_VERSION_SSPI},
1031+
{"TLS-SRP", CURL_VERSION_TLSAUTH_SRP},
1032+
{"HTTP2", CURL_VERSION_HTTP2},
1033+
{"GSSAPI", CURL_VERSION_GSSAPI},
1034+
{"KERBEROS5", CURL_VERSION_KERBEROS5},
1035+
{"UNIX_SOCKETS", CURL_VERSION_UNIX_SOCKETS},
1036+
{"PSL", CURL_VERSION_PSL},
1037+
{"HTTPS_PROXY", CURL_VERSION_HTTPS_PROXY},
1038+
{"MULTI_SSL", CURL_VERSION_MULTI_SSL},
1039+
{"BROTLI", CURL_VERSION_BROTLI},
1040+
#if LIBCURL_VERSION_NUM >= 0x074001 /* Available since 7.64.1 */
1041+
{"ALTSVC", CURL_VERSION_ALTSVC},
1042+
#endif
1043+
#if LIBCURL_VERSION_NUM >= 0x074200 /* Available since 7.66.0 */
1044+
{"HTTP3", CURL_VERSION_HTTP3},
1045+
#endif
1046+
#if LIBCURL_VERSION_NUM >= 0x074800 /* Available since 7.72.0 */
1047+
{"UNICODE", CURL_VERSION_UNICODE},
1048+
{"ZSTD", CURL_VERSION_ZSTD},
1049+
#endif
1050+
#if LIBCURL_VERSION_NUM >= 0x074a00 /* Available since 7.74.0 */
1051+
{"HSTS", CURL_VERSION_HSTS},
1052+
#endif
1053+
#if LIBCURL_VERSION_NUM >= 0x074c00 /* Available since 7.76.0 */
1054+
{"GSASL", CURL_VERSION_GSASL},
1055+
#endif
1056+
};
1057+
1058+
for(i = 0; i < sizeof(feats) / sizeof(feats[0]); i++) {
1059+
if (feats[i].name) {
1060+
add_assoc_bool(&feature_list, feats[i].name, d->features & feats[i].bitmask ? true : false);
1061+
}
1062+
}
1063+
1064+
CAAZ("feature_list", &feature_list);
1065+
}
10031066
CAAL("ssl_version_number", d->ssl_version_num);
10041067
CAAS("version", d->version);
10051068
CAAS("host", d->host);
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
--TEST--
2+
Test curl_version() - feature_list functionality
3+
--EXTENSIONS--
4+
curl
5+
--FILE--
6+
<?php
7+
$info_curl = curl_version();
8+
print_r(array_map(fn ($v) => get_debug_type($v), $info_curl['feature_list']));
9+
10+
ob_start();
11+
phpinfo();
12+
$phpinfo = ob_get_clean();
13+
14+
foreach ($info_curl['feature_list'] as $key => $value) {
15+
if (!is_bool($value)) {
16+
throw new Exception('Found non-bool value');
17+
}
18+
19+
if (!str_contains($phpinfo, $key .' => ' . $value ? 'Yes' : 'No')) {
20+
throw new Exception($key . ' not found in Curl phpinfo()');
21+
}
22+
}
23+
24+
echo "Complete";
25+
?>
26+
--EXPECTF--
27+
Array
28+
(
29+
[AsynchDNS] => bool
30+
[CharConv] => bool
31+
[Debug] => bool
32+
[GSS-Negotiate] => bool
33+
[IDN] => bool
34+
[IPv6] => bool
35+
[krb4] => bool
36+
[Largefile] => bool
37+
[libz] => bool
38+
[NTLM] => bool
39+
[NTLMWB] => bool
40+
[SPNEGO] => bool
41+
[SSL] => bool
42+
[SSPI] => bool
43+
[TLS-SRP] => bool
44+
[HTTP2] => bool
45+
[GSSAPI] => bool
46+
[KERBEROS5] => bool
47+
[UNIX_SOCKETS] => bool
48+
[PSL] => bool
49+
[HTTPS_PROXY] => bool
50+
[MULTI_SSL] => bool
51+
[BROTLI] => bool
52+
%A
53+
)
54+
Complete

ext/ftp/ftp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1704,7 +1704,7 @@ ftp_getdata(ftpbuf_t *ftp)
17041704

17051705
data->listener = fd;
17061706

1707-
#if defined(HAVE_IPV6)
1707+
#ifdef HAVE_IPV6
17081708
if (sa->sa_family == AF_INET6) {
17091709
/* need to use EPRT */
17101710
char eprtarg[INET6_ADDRSTRLEN + sizeof("|x||xxxxx|")];

ext/gd/libgd/gdcache.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,6 @@
4141
/*********************************************************/
4242

4343
#include <stdlib.h>
44-
#if (!defined(__OpenBSD__)) && defined(HAVE_MALLOC_H)
45-
#include <malloc.h>
46-
#endif
4744
#ifndef NULL
4845
#define NULL (void *)0
4946
#endif

ext/mbstring/libmbfl/mbfl/mk_eaw_tbl.awk

100644100755
File mode changed.

0 commit comments

Comments
 (0)