PHP 8.4 INTERNALS UPGRADE NOTES 1. Internal API changes 2. Build system changes 3. Module changes 4. OpCode changes 5. SAPI changes ======================== 1. Internal API changes ======================== * zend_register_module_ex() now takes an additional int module_type argument. This function will also assign the module number and type, there is no need to do this at the call site anymore. Writing the handle should happen after successful registration. * ZPP now accepts a F or Z_PARAM_FUNC_NO_TRAMPOLINE_FREE type check. This is identical to the 'f' or Z_PARAM_FUNC type check, except the FCC is always initialized because it doesn't free trampolines. Trampolines MUST be freed using zend_release_fcall_info_cache() or consumed. Z_PARAM_FUNC_EX2 was added as well with the same arguments as Z_PARAM_FUNC_EX plus an additional argument free_trampoline. * The zend_object_iterator_funcs valid member has changed its signature from int(*)(zend_object_iterator *) to zend_result(*)(zend_object_iterator *) to be more in line with what callbacks are returning. * The backwards compatibility headers ext/standard/{php_lcg.h,php_mt_rand.h, php_rand.h,php_random.h} have been removed. Include ext/random/php_random.h directly. * The zend_*printf family of functions now supports the "%S" modifier to print out zend_string*. This won't cut off the string if it embeds a NUL byte. * The inet_aton() and win32/inet.h have been removed. Use platform-agnostic inet_pton() from arpa/inet.h or ws2tcpip.h on Windows. * zend_mm_set_custom_debug_handlers() has been removed from ZendMM, use zend_mm_set_custom_handlers() instead which now supports DEBUG builds * zend_mm_set_custom_handlers() has changed its signature from void()(zend_mm_heap *heap, void* (*_malloc)(size_t), void (*_free)(void*), void* (*_realloc)(void*, size_t)) to void()(zend_mm_heap *heap, void* (*_malloc)(size_t ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC), void (*_free)(void* ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC), void* (*_realloc)(void*, size_t ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)) * zend_mm_get_custom_handlers() has changed its signature from void()(zend_mm_heap *heap, void* (**_malloc)(size_t), void (**_free)(void*), void* (**_realloc)(void*, size_t)) to void()(zend_mm_heap *heap, void* (**_malloc)(size_t ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC), void (**_free)(void* ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC), void* (**_realloc)(void*, size_t ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)) * __zend_malloc() has changed their signature from void(*)(size_t) to void(*)(size_t ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) * __zend_calloc() has changed their signature from void(*)(size_t, size_t) to void(*)(size_t, size_t ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) * __zend_realloc() has changed their signature from void(*)(void *, size_t) to void(*)(void *, size_t ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) ======================== 2. Build system changes ======================== a. Abstract - The configure option --with-imap has been removed. - The configure option --with-mhash emits deprecation warning. - The configure option --with-pdo-oci has been removed. - The configure option --with-pspell has been removed. - Symbol SIZEOF_SHORT removed (size of 2 on 32-bit and 64-bit platforms). - Symbol DBA_CDB_MAKE removed in ext/dba. - Symbol HAVE_LIBM has been removed. - Symbol HAVE_INET_ATON has been removed. - The Zend/zend_istdiostream.h header has been removed. b. Unix build system changes - The configure option --with-imap-ssl has been removed. - The configure option --with-oci8 has been removed. - The configure option --with-zlib-dir has been removed. - The configure option --with-kerberos has been removed. - COOKIE_IO_FUNCTIONS_T symbol has been removed (use cookie_io_functions_t). - HAVE_SOCKADDR_UN_SUN_LEN symbol renamed to HAVE_STRUCT_SOCKADDR_UN_SUN_LEN. - HAVE_UTSNAME_DOMAINNAME symbol renamed to HAVE_STRUCT_UTSNAME_DOMAINNAME. - PHP_CHECK_IN_ADDR_T M4 macro and 'in_addr_t' fallback definition to 'u_int' removed (use AC_CHECK_TYPES Autoconf macro instead). - HAVE_ODBC2 symbol has been removed in ext/odbc. - Removed linking with obsolete dnet_stub library in ext/pdo_dblib. - Removed checking and linking with obsolete libbind for some functions. - Symbol HAVE_JSON has been removed (ext/json is always available since PHP 8.0). - Symbol DARWIN has been removed (use __APPLE__ to target Darwin systems). - Symbol MISSING_FCLOSE_DECL and M4 macro PHP_MISSING_FCLOSE_DECL removed. - Symbol HAVE_BSD_ICONV has been removed. - Symbol ZEND_FIBER_ASM has been removed. - Symbols HAVE_DLOPEN and HAVE_DLSYM have been removed. - Symbol HAVE_MYSQL has been removed. - M4 macro PHP_DEFINE (atomic includes) removed (use AC_DEFINE and config.h). - M4 macro PHP_WITH_SHARED has been removed (use PHP_ARG_WITH). - M4 macro PHP_STRUCT_FLOCK has been removed (use AC_CHECK_TYPES). - M4 macro PHP_SOCKADDR_CHECKS has been removed (use AC_CHECK_TYPES and AC_CHECK_MEMBERS). - M4 macro PHP_CHECK_GCC_ARG has been removed since PHP 8.0 (use AX_CHECK_COMPILE_FLAG). - Added php-config --lib-dir and --lib-embed options for PHP embed SAPI. c. Windows build system changes - The configure options --with-oci8-11g, --with-oci8-12c, --with-oci8-19 have been removed. - Added Bison flag '-Wall' when generating lexer files as done in *nix build system. - HAVE_WIN32_NATIVE_THREAD, USE_WIN32_NATIVE_THREAD, ENABLE_THREADS symbols in ext/mbstring/libmbfl removed. - FIBER_ASSEMBLER and FIBER_ASM_ARCH Makefile variables removed in favor of PHP_ASSEMBLER and FIBER_ASM_ABI. - HAVE_PHP_SOAP symbol renamed to HAVE_SOAP. - Unused symbols CONFIGURATION_FILE_PATH, DISCARD_PATH, HAVE_ERRMSG_H, HAVE_REGCOMP, HAVE_RINT, NEED_ISBLANK, PHP_URL_FOPEN, REGEX, HSREGEX, USE_CONFIG_FILE have been removed. ======================== 3. Module changes ======================== a. ext/dom - dom_read_t and dom_write_t now expect the function to return zend_result instead of int. - The macros DOM_NO_ARGS() and DOM_NOT_IMPLEMENTED() have been removed. - New public APIs are available to handle callbacks from XPath, see xpath_callbacks.h. - Added public APIs to manipulate namespace data, see namespace_compat.h. - php_dom_create_object() now no longer accepts a NULL obj argument. - Removed the `ret` argument from the DOM_RET_OBJ macro, use the return value instead. - Removed DOM_XMLNS_NAMESPACE from xml_common.h. Use DOM_XMLNS_NS_URI from namespace_compat.h instead. - Added php_dom_get_ns_mapper(), php_dom_next_in_tree_order(), php_dom_follow_spec_doc_ref(), and php_dom_follow_spec_doc_ref(). b. ext/random - The macro RAND_RANGE_BADSCALING() has been removed. The implementation should either be inlined and undefined behavior fixed or it should be replaced by a non-biased scaler. - The generate member of a php_random_algo is now expected to return the new php_random_result struct, replacing the last_generated_size member of the php_random_status struct and the generate_size member of the php_random_algo struct. - The php_random_status struct has been removed, since the previous change reduced it to a single void* member containing the actual state, resulting in needless indirection. Functions taking a php_random_algo struct pointer and a php_random_status struct pointer as separate parameters now take a single php_random_algo_with_state struct by value, making it easier to pass around the state with its associated algorithm and thus reducing the chance for mistakes. - The seed member of a php_random_algo has been removed. As a replacement engine-specific seeding functions are now exposed. This change allows users to better take engine-specific behavior into account. As an example Mt19937 ignored the upper half of the seed parameter of the generic seeding function. - The CSPRNG API (php_random_(bytes|int)_*) is now provided by the new and much smaller php_random_csprng.h header. The new header is included in php_random.h for compatibility with existing users. - A new php_random_generate_fallback_seed() function has been added as a replacement for the generically named GENERATE_SEED(). The internal implementation has been improved to generate better seeds, however any users should use the opportunity to verify that seeding is first attempted using the CSPRNG for better output size flexibility. c. ext/xsl - The function php_xsl_create_object() was removed as it was not used nor exported. d. ext/libxml - Added php_libxml_pretend_ctx_error_ex() to emit errors as if they had come from libxml. - Removed the "properties" HashTable field from php_libxml_node_object. - Added a way to attached private data to a php_libxml_ref_obj. - Added a way to fix a class type onto php_libxml_ref_obj. - Added php_libxml_uses_internal_errors(). e. ext/date - Added the php_format_date_ex() API to format instances of php_date_obj. - Added the php_date_initialize_from_ts_long() and php_date_initialize_from_ts_double() to initialize a php_date_obj with the given unix timestamp using GMT +00:00. f. ext/pcre - php_pcre_match_impl() now no longer has a use_flags argument. When flags should be ignored, pass 0 to the flags argument. - php_pcre_match_impl() and pcre_get_compiled_regex_cache_ex() now use proper boolean argument types instead of integer types. - pcre_get_compiled_regex_cache_ex() now provides an option to collect extra options (from modifiers used in the expression, for example), and calls pcre2_set_compile_extra_options() with those options. g. ext/standard - Added the php_base64_encode_ex() API with flag parameters, value can be PHP_BASE64_NO_PADDING to encode without the padding character '='. ======================== 4. OpCode changes ======================== * New FRAMELESS_ICALL_[0,3] opcodes for faster internal function calls have been added. These opcodes don't create a stack frame, but pass arguments via opcode operands. They only work for functions that are known at compile-time, and that provide a frameless handler (search for usages of the ZEND_FRAMELESS_FUNCTION macro). ======================== 5. SAPI changes ========================