Skip to content

Commit

Permalink
Merge branch 'php:master' into exif_heif
Browse files Browse the repository at this point in the history
  • Loading branch information
benstonezhang authored Feb 21, 2024
2 parents 25308f6 + ba0f9fb commit 47ccc3b
Show file tree
Hide file tree
Showing 45 changed files with 1,754 additions and 386 deletions.
1 change: 1 addition & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ PHP NEWS
- Curl:
. Deprecated the CURLOPT_BINARYTRANSFER constant. (divinity76)
. Bumped required libcurl version to 7.61.0. (Ayesh)
. Added feature_list key to the curl_version() return value (Ayesh)

- Date:
. Added DateTime[Immutable]::createFromTimestamp. (Marc Bennewitz)
Expand Down
3 changes: 3 additions & 0 deletions UPGRADING
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,9 @@ PHP 8.4 UPGRADE NOTES

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

- Date:
. Calling DatePeriod::__construct(string $isostr, int $options = 0) is
Expand Down
2 changes: 0 additions & 2 deletions Zend/Optimizer/zend_func_infos.h
Original file line number Diff line number Diff line change
Expand Up @@ -517,9 +517,7 @@ static const func_info_t func_infos[] = {
F1("sha1", MAY_BE_STRING),
F1("sha1_file", MAY_BE_STRING|MAY_BE_FALSE),
F1("inet_ntop", MAY_BE_STRING|MAY_BE_FALSE),
#if defined(HAVE_INET_PTON)
F1("inet_pton", MAY_BE_STRING|MAY_BE_FALSE),
#endif
F1("metaphone", MAY_BE_STRING),
F1("headers_list", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_STRING),
F1("htmlspecialchars", MAY_BE_STRING),
Expand Down
2 changes: 2 additions & 0 deletions Zend/zend.c
Original file line number Diff line number Diff line change
Expand Up @@ -1183,6 +1183,8 @@ void zend_shutdown(void) /* {{{ */
#endif
zend_destroy_rsrc_list_dtors();

zend_unload_modules();

zend_optimizer_shutdown();
startup_done = false;
}
Expand Down
1 change: 1 addition & 0 deletions Zend/zend.h
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ void zend_shutdown(void);
void zend_register_standard_ini_entries(void);
zend_result zend_post_startup(void);
void zend_set_utility_values(zend_utility_values *utility_values);
void zend_unload_modules(void);

ZEND_API ZEND_COLD ZEND_NORETURN void _zend_bailout(const char *filename, uint32_t lineno);
ZEND_API size_t zend_get_page_size(void);
Expand Down
43 changes: 37 additions & 6 deletions Zend/zend_API.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ ZEND_API HashTable module_registry;
static zend_module_entry **module_request_startup_handlers;
static zend_module_entry **module_request_shutdown_handlers;
static zend_module_entry **module_post_deactivate_handlers;
static zend_module_entry **modules_dl_loaded;

static zend_class_entry **class_cleanup_handlers;

Expand Down Expand Up @@ -2398,6 +2399,7 @@ ZEND_API void zend_collect_module_handlers(void) /* {{{ */
int startup_count = 0;
int shutdown_count = 0;
int post_deactivate_count = 0;
int dl_loaded_count = 0;
zend_class_entry *ce;
int class_count = 0;

Expand All @@ -2412,6 +2414,9 @@ ZEND_API void zend_collect_module_handlers(void) /* {{{ */
if (module->post_deactivate_func) {
post_deactivate_count++;
}
if (module->handle) {
dl_loaded_count++;
}
} ZEND_HASH_FOREACH_END();
module_request_startup_handlers = (zend_module_entry**)realloc(
module_request_startup_handlers,
Expand All @@ -2424,6 +2429,9 @@ ZEND_API void zend_collect_module_handlers(void) /* {{{ */
module_request_shutdown_handlers[shutdown_count] = NULL;
module_post_deactivate_handlers = module_request_shutdown_handlers + shutdown_count + 1;
module_post_deactivate_handlers[post_deactivate_count] = NULL;
/* Cannot reuse module_request_startup_handlers because it is freed in zend_destroy_modules, which happens before zend_unload_modules. */
modules_dl_loaded = realloc(modules_dl_loaded, sizeof(zend_module_entry*) * (dl_loaded_count + 1));
modules_dl_loaded[dl_loaded_count] = NULL;
startup_count = 0;

ZEND_HASH_MAP_FOREACH_PTR(&module_registry, module) {
Expand All @@ -2436,6 +2444,9 @@ ZEND_API void zend_collect_module_handlers(void) /* {{{ */
if (module->post_deactivate_func) {
module_post_deactivate_handlers[--post_deactivate_count] = module;
}
if (module->handle) {
modules_dl_loaded[--dl_loaded_count] = module;
}
} ZEND_HASH_FOREACH_END();

/* Collect internal classes with static members */
Expand Down Expand Up @@ -3238,18 +3249,23 @@ void module_destructor(zend_module_entry *module) /* {{{ */
clean_module_functions(module);
}

#if HAVE_LIBDL
if (module->handle && !getenv("ZEND_DONT_UNLOAD_MODULES")) {
DL_UNLOAD(module->handle);
}
#endif

#if ZEND_RC_DEBUG
zend_rc_debug = orig_rc_debug;
#endif
}
/* }}} */

void module_registry_unload(const zend_module_entry *module)
{
#if HAVE_LIBDL
if (!getenv("ZEND_DONT_UNLOAD_MODULES")) {
DL_UNLOAD(module->handle);
}
#else
ZEND_IGNORE_VALUE(module);
#endif
}

ZEND_API void zend_activate_modules(void) /* {{{ */
{
zend_module_entry **p = module_request_startup_handlers;
Expand Down Expand Up @@ -3294,6 +3310,18 @@ ZEND_API void zend_deactivate_modules(void) /* {{{ */
}
/* }}} */

void zend_unload_modules(void) /* {{{ */
{
zend_module_entry **modules = modules_dl_loaded;
while (*modules) {
module_registry_unload(*modules);
modules++;
}
free(modules_dl_loaded);
modules_dl_loaded = NULL;
}
/* }}} */

ZEND_API void zend_post_deactivate_modules(void) /* {{{ */
{
if (EG(full_tables_cleanup)) {
Expand All @@ -3312,6 +3340,9 @@ ZEND_API void zend_post_deactivate_modules(void) /* {{{ */
break;
}
module_destructor(module);
if (module->handle) {
module_registry_unload(module);
}
zend_string_release_ex(key, 0);
} ZEND_HASH_MAP_FOREACH_END_DEL();
} else {
Expand Down
2 changes: 1 addition & 1 deletion Zend/zend_modules.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ extern ZEND_API HashTable module_registry;

void module_destructor(zend_module_entry *module);
int module_registry_request_startup(zend_module_entry *module);
int module_registry_unload_temp(const zend_module_entry *module);
void module_registry_unload(const zend_module_entry *module);
END_EXTERN_C()

#endif
Empty file modified build/config.guess
100644 → 100755
Empty file.
Empty file modified build/config.sub
100644 → 100755
Empty file.
9 changes: 2 additions & 7 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,6 @@ dnl ----------------------------------------------------------------------------

dnl QNX requires unix.h to allow functions in libunix to work properly.
AC_CHECK_HEADERS([ \
stdint.h \
dirent.h \
sys/param.h \
sys/types.h \
Expand All @@ -398,7 +397,6 @@ grp.h \
ieeefp.h \
langinfo.h \
linux/sock_diag.h \
malloc.h \
os/signpost.h \
poll.h \
pty.h \
Expand Down Expand Up @@ -603,7 +601,6 @@ getgrnam_r \
getpwuid_r \
getwd \
glob \
inet_pton \
localtime_r \
lchown \
memcntl \
Expand Down Expand Up @@ -640,10 +637,8 @@ memrchr \
mempcpy \
)

AC_CHECK_FUNC(inet_ntop,[],[
AC_MSG_ERROR([Cannot find inet_ntop which is required])
]
)
AC_CHECK_FUNC([inet_ntop],,[AC_MSG_ERROR([Required inet_ntop not found.])])
AC_CHECK_FUNC([inet_pton],,[AC_MSG_ERROR([Required inet_pton not found.])])

dnl Check for strerror_r, and if its a POSIX-compatible or a GNU specific version.
AC_FUNC_STRERROR_R
Expand Down
63 changes: 63 additions & 0 deletions ext/curl/interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ PHP_MINFO_FUNCTION(curl)
php_info_print_table_row(2, "Age", str);

/* To update on each new cURL release using src/main.c in cURL sources */
/* make sure to sync this list with curl_version as well */
if (d->features) {
struct feat {
const char *name;
Expand Down Expand Up @@ -1000,6 +1001,68 @@ PHP_FUNCTION(curl_version)
CAAL("version_number", d->version_num);
CAAL("age", d->age);
CAAL("features", d->features);
/* Add an array of features */
{
struct feat {
const char *name;
int bitmask;
};

unsigned int i;
zval feature_list;
array_init(&feature_list);

/* Sync this list with PHP_MINFO_FUNCTION(curl) as well */
static const struct feat feats[] = {
{"AsynchDNS", CURL_VERSION_ASYNCHDNS},
{"CharConv", CURL_VERSION_CONV},
{"Debug", CURL_VERSION_DEBUG},
{"GSS-Negotiate", CURL_VERSION_GSSNEGOTIATE},
{"IDN", CURL_VERSION_IDN},
{"IPv6", CURL_VERSION_IPV6},
{"krb4", CURL_VERSION_KERBEROS4},
{"Largefile", CURL_VERSION_LARGEFILE},
{"libz", CURL_VERSION_LIBZ},
{"NTLM", CURL_VERSION_NTLM},
{"NTLMWB", CURL_VERSION_NTLM_WB},
{"SPNEGO", CURL_VERSION_SPNEGO},
{"SSL", CURL_VERSION_SSL},
{"SSPI", CURL_VERSION_SSPI},
{"TLS-SRP", CURL_VERSION_TLSAUTH_SRP},
{"HTTP2", CURL_VERSION_HTTP2},
{"GSSAPI", CURL_VERSION_GSSAPI},
{"KERBEROS5", CURL_VERSION_KERBEROS5},
{"UNIX_SOCKETS", CURL_VERSION_UNIX_SOCKETS},
{"PSL", CURL_VERSION_PSL},
{"HTTPS_PROXY", CURL_VERSION_HTTPS_PROXY},
{"MULTI_SSL", CURL_VERSION_MULTI_SSL},
{"BROTLI", CURL_VERSION_BROTLI},
#if LIBCURL_VERSION_NUM >= 0x074001 /* Available since 7.64.1 */
{"ALTSVC", CURL_VERSION_ALTSVC},
#endif
#if LIBCURL_VERSION_NUM >= 0x074200 /* Available since 7.66.0 */
{"HTTP3", CURL_VERSION_HTTP3},
#endif
#if LIBCURL_VERSION_NUM >= 0x074800 /* Available since 7.72.0 */
{"UNICODE", CURL_VERSION_UNICODE},
{"ZSTD", CURL_VERSION_ZSTD},
#endif
#if LIBCURL_VERSION_NUM >= 0x074a00 /* Available since 7.74.0 */
{"HSTS", CURL_VERSION_HSTS},
#endif
#if LIBCURL_VERSION_NUM >= 0x074c00 /* Available since 7.76.0 */
{"GSASL", CURL_VERSION_GSASL},
#endif
};

for(i = 0; i < sizeof(feats) / sizeof(feats[0]); i++) {
if (feats[i].name) {
add_assoc_bool(&feature_list, feats[i].name, d->features & feats[i].bitmask ? true : false);
}
}

CAAZ("feature_list", &feature_list);
}
CAAL("ssl_version_number", d->ssl_version_num);
CAAS("version", d->version);
CAAS("host", d->host);
Expand Down
54 changes: 54 additions & 0 deletions ext/curl/tests/curl_version_features-array.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
--TEST--
Test curl_version() - feature_list functionality
--EXTENSIONS--
curl
--FILE--
<?php
$info_curl = curl_version();
print_r(array_map(fn ($v) => get_debug_type($v), $info_curl['feature_list']));

ob_start();
phpinfo();
$phpinfo = ob_get_clean();

foreach ($info_curl['feature_list'] as $key => $value) {
if (!is_bool($value)) {
throw new Exception('Found non-bool value');
}

if (!str_contains($phpinfo, $key .' => ' . $value ? 'Yes' : 'No')) {
throw new Exception($key . ' not found in Curl phpinfo()');
}
}

echo "Complete";
?>
--EXPECTF--
Array
(
[AsynchDNS] => bool
[CharConv] => bool
[Debug] => bool
[GSS-Negotiate] => bool
[IDN] => bool
[IPv6] => bool
[krb4] => bool
[Largefile] => bool
[libz] => bool
[NTLM] => bool
[NTLMWB] => bool
[SPNEGO] => bool
[SSL] => bool
[SSPI] => bool
[TLS-SRP] => bool
[HTTP2] => bool
[GSSAPI] => bool
[KERBEROS5] => bool
[UNIX_SOCKETS] => bool
[PSL] => bool
[HTTPS_PROXY] => bool
[MULTI_SSL] => bool
[BROTLI] => bool
%A
)
Complete
2 changes: 1 addition & 1 deletion ext/ftp/ftp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1704,7 +1704,7 @@ ftp_getdata(ftpbuf_t *ftp)

data->listener = fd;

#if defined(HAVE_IPV6)
#ifdef HAVE_IPV6
if (sa->sa_family == AF_INET6) {
/* need to use EPRT */
char eprtarg[INET6_ADDRSTRLEN + sizeof("|x||xxxxx|")];
Expand Down
3 changes: 0 additions & 3 deletions ext/gd/libgd/gdcache.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@
/*********************************************************/

#include <stdlib.h>
#if (!defined(__OpenBSD__)) && defined(HAVE_MALLOC_H)
#include <malloc.h>
#endif
#ifndef NULL
#define NULL (void *)0
#endif
Expand Down
Empty file modified ext/mbstring/libmbfl/mbfl/mk_eaw_tbl.awk
100644 → 100755
Empty file.
Loading

0 comments on commit 47ccc3b

Please sign in to comment.