diff --git a/.github/scripts/windows/build_task.bat b/.github/scripts/windows/build_task.bat index ec4ce4459d088..7a2824e299708 100644 --- a/.github/scripts/windows/build_task.bat +++ b/.github/scripts/windows/build_task.bat @@ -36,7 +36,6 @@ set CFLAGS=/W1 /WX cmd /c configure.bat ^ --enable-snapshot-build ^ --disable-debug-pack ^ - --enable-com-dotnet=shared ^ --without-analyzer ^ --enable-object-out-dir=%PHP_BUILD_OBJ_DIR% ^ --with-php-build=%DEPS_DIR% ^ diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml index 2945fc60c511a..dbddbdc5d89b3 100644 --- a/.github/workflows/labeler.yml +++ b/.github/workflows/labeler.yml @@ -7,6 +7,7 @@ permissions: jobs: triage: + if: github.repository == 'php/php-src' permissions: pull-requests: write runs-on: ubuntu-latest diff --git a/NEWS b/NEWS index bce8cb9ea040b..d2b21046b1c52 100644 --- a/NEWS +++ b/NEWS @@ -8,6 +8,7 @@ PHP NEWS - Core: . Fixed bug GH-16665 (\array and \callable should not be usable in class_alias). (nielsdos) + . Added PHP_BUILD_DATE constant. (cmb) - Curl: . Added curl_multi_get_handles(). (timwolla) diff --git a/UPGRADING b/UPGRADING index 0a2eb2867489c..0106d41269b1c 100644 --- a/UPGRADING +++ b/UPGRADING @@ -129,6 +129,9 @@ PHP 8.5 UPGRADE NOTES 10. New Global Constants ======================================== +- Core: + . PHP_BUILD_DATE. + - POSIX: . POSIX_SC_OPEN_MAX. @@ -147,6 +150,11 @@ PHP 8.5 UPGRADE NOTES PHP_RELEASE_VERSION are now always numbers. Previously, they have been strings for buildconf builds. +* COM: + . The extension is now build shared by default; previously it defaulted to a + static extension, although the official Windows binaries built a shared + extension. + * FFI: . It is no longer necessary to specify the library when using FFI::cdef() and FFI::load(). However, this convenience feature should not be used in diff --git a/Zend/tests/gh16630.phpt b/Zend/tests/gh16630.phpt new file mode 100644 index 0000000000000..62d6c9956a7eb --- /dev/null +++ b/Zend/tests/gh16630.phpt @@ -0,0 +1,19 @@ +--TEST-- +GH-16630 (UAF in lexer with encoding translation and heredocs) +--EXTENSIONS-- +mbstring +--INI-- +zend.multibyte=On +zend.script_encoding=ISO-8859-1 +internal_encoding=EUC-JP +--FILE-- + +--EXPECT-- +heredoc +text diff --git a/Zend/zend_hash.h b/Zend/zend_hash.h index 5865c735eec48..d543dae2bab59 100644 --- a/Zend/zend_hash.h +++ b/Zend/zend_hash.h @@ -30,12 +30,13 @@ #define HASH_KEY_IS_LONG 2 #define HASH_KEY_NON_EXISTENT 3 -#define HASH_UPDATE (1<<0) -#define HASH_ADD (1<<1) -#define HASH_UPDATE_INDIRECT (1<<2) -#define HASH_ADD_NEW (1<<3) -#define HASH_ADD_NEXT (1<<4) -#define HASH_LOOKUP (1<<5) +#define HASH_UPDATE (1<<0) /* Create new entry, or update the existing one. */ +#define HASH_ADD (1<<1) /* Create new entry, or fail if it exists. */ +#define HASH_UPDATE_INDIRECT (1<<2) /* If the given ht entry is an indirect zval, unwrap it before writing to it. \ + * When used with HASH_ADD, writing is allowed if the target zval is IS_UNDEF. */ +#define HASH_ADD_NEW (1<<3) /* Used when the offset is known not to exist. */ +#define HASH_ADD_NEXT (1<<4) /* Append to an array. (e.g. $array[] = 42;) */ +#define HASH_LOOKUP (1<<5) /* Look up an existing entry, or create one with a NULL value. */ #define HASH_FLAG_CONSISTENCY ((1<<0) | (1<<1)) #define HASH_FLAG_PACKED (1<<2) diff --git a/Zend/zend_language_scanner.l b/Zend/zend_language_scanner.l index 194f5a995fbce..7ae73875926eb 100644 --- a/Zend/zend_language_scanner.l +++ b/Zend/zend_language_scanner.l @@ -275,7 +275,7 @@ ZEND_API void zend_restore_lexical_state(zend_lex_state *lex_state) CG(zend_lineno) = lex_state->lineno; zend_restore_compiled_filename(lex_state->filename); - if (SCNG(script_filtered)) { + if (SCNG(script_filtered) && SCNG(script_filtered) != lex_state->script_filtered) { efree(SCNG(script_filtered)); SCNG(script_filtered) = NULL; } diff --git a/ext/com_dotnet/config.w32 b/ext/com_dotnet/config.w32 index cc548ac48c777..ebd55b1b3f066 100644 --- a/ext/com_dotnet/config.w32 +++ b/ext/com_dotnet/config.w32 @@ -1,6 +1,6 @@ // vim:ft=javascript -ARG_ENABLE("com-dotnet", "COM and .Net support", "yes"); +ARG_ENABLE("com-dotnet", "COM and .Net support", "yes,shared"); if (PHP_COM_DOTNET == "yes") { CHECK_LIB('oleaut32.lib', 'com_dotnet'); diff --git a/ext/opcache/config.w32 b/ext/opcache/config.w32 index 16c137f47a810..fa89ca1f18a39 100644 --- a/ext/opcache/config.w32 +++ b/ext/opcache/config.w32 @@ -1,5 +1,5 @@ ARG_ENABLE("opcache", "whether to enable Zend OPcache support", "yes"); -ARG_ENABLE("opcache-jit", "whether to enable JIT", "yes"); +ARG_ENABLE("opcache-jit", "whether to enable JIT (not supported for ARM64)", "yes"); if (PHP_OPCACHE != "no") { @@ -22,7 +22,9 @@ if (PHP_OPCACHE != "no") { ADD_EXTENSION_DEP('opcache', 'pcre'); if (PHP_OPCACHE_JIT == "yes") { - if (CHECK_HEADER_ADD_INCLUDE("ir/ir.h", "CFLAGS_OPCACHE", PHP_OPCACHE + ";ext\\opcache\\jit")) { + if (TARGET_ARCH == 'arm64') { + WARNING("JIT not enabled; not yet supported for ARM64"); + } else if (CHECK_HEADER_ADD_INCLUDE("ir/ir.h", "CFLAGS_OPCACHE", PHP_OPCACHE + ";ext\\opcache\\jit")) { var dasm_flags = (X64 ? "-D X64=1" : "") + (X64 ? " -D X64WIN=1" : "") + " -D WIN=1"; var ir_target = (X64 ? "IR_TARGET_X64" : "IR_TARGET_X86"); var ir_src = "ir_strtab.c ir_cfg.c ir_sccp.c ir_gcm.c ir_ra.c ir_save.c \ diff --git a/ext/opcache/jit/zend_jit_ir.c b/ext/opcache/jit/zend_jit_ir.c index 9124b8400bcea..4767b55cb9547 100644 --- a/ext/opcache/jit/zend_jit_ir.c +++ b/ext/opcache/jit/zend_jit_ir.c @@ -1826,6 +1826,9 @@ static void jit_ZVAL_PTR_DTOR(zend_jit_ctx *jit, ir_END_list(end_inputs); ir_IF_FALSE(if_may_not_leak); + if (opline) { + jit_SET_EX_OPLINE(jit, opline); + } ir_CALL_1(IR_VOID, ir_CONST_FC_FUNC(gc_possible_root), ref); } @@ -6518,6 +6521,9 @@ static int zend_jit_assign_to_variable(zend_jit_ctx *jit, if (RC_MAY_BE_N(var_info) && (var_info & (MAY_BE_ARRAY|MAY_BE_OBJECT)) != 0) { ir_ref if_may_leak = jit_if_GC_MAY_NOT_LEAK(jit, ref); ir_IF_FALSE(if_may_leak); + if (opline) { + jit_SET_EX_OPLINE(jit, opline); + } ir_CALL_1(IR_VOID, ir_CONST_FC_FUNC(gc_possible_root), ref); if (Z_MODE(var_addr) == IS_REG || Z_MODE(res_addr) == IS_REG) { @@ -6545,6 +6551,9 @@ static int zend_jit_assign_to_variable(zend_jit_ctx *jit, if (var_info & (MAY_BE_ARRAY|MAY_BE_OBJECT)) { ir_ref if_may_leak = jit_if_GC_MAY_NOT_LEAK(jit, ref); ir_IF_FALSE(if_may_leak); + if (opline) { + jit_SET_EX_OPLINE(jit, opline); + } ir_CALL_1(IR_VOID, ir_CONST_FC_FUNC(gc_possible_root), ref); ir_END_list(simple_inputs); ir_IF_TRUE(if_may_leak); @@ -11410,6 +11419,9 @@ static int zend_jit_bind_global(zend_jit_ctx *jit, const zend_op *opline, uint32 ir_IF_TRUE(if_may_not_leak); ir_END_list(end_inputs); ir_IF_FALSE(if_may_not_leak); + if (opline) { + jit_SET_EX_OPLINE(jit, opline); + } ir_CALL_1(IR_VOID, ir_CONST_FC_FUNC(gc_possible_root), ref2); } if (op1_info & ((MAY_BE_ANY|MAY_BE_UNDEF) - (MAY_BE_OBJECT|MAY_BE_RESOURCE))) { diff --git a/ext/standard/info.c b/ext/standard/info.c index 8a706ef62eb57..aa03be761c052 100644 --- a/ext/standard/info.c +++ b/ext/standard/info.c @@ -801,7 +801,7 @@ PHPAPI ZEND_COLD void php_print_info(int flag) php_info_print_box_end(); php_info_print_table_start(); php_info_print_table_row(2, "System", ZSTR_VAL(php_uname)); - php_info_print_table_row(2, "Build Date", __DATE__ " " __TIME__); + php_info_print_table_row(2, "Build Date", php_build_date); #ifdef PHP_BUILD_SYSTEM php_info_print_table_row(2, "Build System", PHP_BUILD_SYSTEM); #endif diff --git a/main/main.c b/main/main.c index 0b38f303c58fc..0f422fd3978f1 100644 --- a/main/main.c +++ b/main/main.c @@ -97,6 +97,8 @@ PHPAPI size_t core_globals_offset; #define SAFE_FILENAME(f) ((f)?(f):"-") +const char php_build_date[] = __DATE__ " " __TIME__; + PHPAPI const char *php_version(void) { return PHP_VERSION; @@ -110,8 +112,8 @@ PHPAPI unsigned int php_version_id(void) PHPAPI char *php_get_version(sapi_module_struct *sapi_module) { char *version_info; - spprintf(&version_info, 0, "PHP %s (%s) (built: %s %s) (%s)\nCopyright (c) The PHP Group\n%s%s", - PHP_VERSION, sapi_module->name, __DATE__, __TIME__, + spprintf(&version_info, 0, "PHP %s (%s) (built: %s) (%s)\nCopyright (c) The PHP Group\n%s%s", + PHP_VERSION, sapi_module->name, php_build_date, #ifdef ZTS "ZTS" #else diff --git a/main/main.stub.php b/main/main.stub.php index b5f848dacc82b..3359d4a1cd0bf 100644 --- a/main/main.stub.php +++ b/main/main.stub.php @@ -34,6 +34,13 @@ * @cvalue PHP_VERSION_ID */ const PHP_VERSION_ID = UNKNOWN; + +/** + * @var string + * @cvalue php_build_date + */ +const PHP_BUILD_DATE = UNKNOWN; + /** * @var bool * @cvalue PHP_ZTS diff --git a/main/main_arginfo.h b/main/main_arginfo.h index 28a7d15f89661..f0d2599baf473 100644 --- a/main/main_arginfo.h +++ b/main/main_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 793b455a47a0422cee767ef2f6a448a369520542 */ + * Stub hash: cb5c9a3e48b18a773264378099267550ca9e4fc1 */ static void register_main_symbols(int module_number) { @@ -9,6 +9,7 @@ static void register_main_symbols(int module_number) REGISTER_LONG_CONSTANT("PHP_RELEASE_VERSION", PHP_RELEASE_VERSION, CONST_PERSISTENT); REGISTER_STRING_CONSTANT("PHP_EXTRA_VERSION", PHP_EXTRA_VERSION, CONST_PERSISTENT); REGISTER_LONG_CONSTANT("PHP_VERSION_ID", PHP_VERSION_ID, CONST_PERSISTENT); + REGISTER_STRING_CONSTANT("PHP_BUILD_DATE", php_build_date, CONST_PERSISTENT); REGISTER_BOOL_CONSTANT("PHP_ZTS", PHP_ZTS, CONST_PERSISTENT); REGISTER_BOOL_CONSTANT("PHP_DEBUG", PHP_DEBUG, CONST_PERSISTENT); REGISTER_STRING_CONSTANT("PHP_OS", PHP_OS_STR, CONST_PERSISTENT); diff --git a/main/php.h b/main/php.h index a7ff4b6e35bea..5c0b89c328375 100644 --- a/main/php.h +++ b/main/php.h @@ -265,6 +265,8 @@ END_EXTERN_C() extern char **environ; #endif /* ifndef PHP_WIN32 */ +extern const char php_build_date[]; + #ifdef PHP_PWRITE_64 ssize_t pwrite(int, void *, size_t, off64_t); #endif diff --git a/tests/basic/build_date.phpt b/tests/basic/build_date.phpt new file mode 100644 index 0000000000000..44f09bab59aea --- /dev/null +++ b/tests/basic/build_date.phpt @@ -0,0 +1,8 @@ +--TEST-- +PHP_BUILD_DATE +--FILE-- + +--EXPECTREGEX-- +string\(20\) "[A-Za-z]{3} \d{2} \d{4} \d{2}:\d{2}:\d{2}"