Merge branch 'PHP-8.3' into PHP-8.4
Some checks are pending
Push / LINUX_X32_DEBUG_ZTS (push) Has been skipped
Push / MACOS_ARM64_DEBUG_NTS (push) Waiting to run
Push / WINDOWS_X64_ZTS (push) Waiting to run
Push / LINUX_X64_RELEASE_NTS (push) Has been skipped
Push / LINUX_X64_DEBUG_ZTS_ASAN (push) Has been skipped
Push / BENCHMARKING (push) Has been skipped
Push / FREEBSD (push) Has been skipped

* PHP-8.3:
  Fix "Constant already defined" warning with repeated inclusion of file with __halt_compiler()
This commit is contained in:
Ilija Tovilo 2025-08-14 12:15:00 +02:00
commit 708d8e9cfd
No known key found for this signature in database
GPG key ID: 115CEA7A713E12E9
5 changed files with 26 additions and 3 deletions

4
NEWS
View file

@ -2,6 +2,10 @@ PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? ????, PHP 8.4.13
- Core:
. Fixed bug GH-18850 (Repeated inclusion of file with __halt_compiler()
triggers "Constant already defined" warning). (ilutov)
- OpenSSL:
. Fixed bug GH-19245 (Success error message on TLS stream accept failure).
(Jakub Zelenka)

View file

@ -0,0 +1,5 @@
<?php
var_dump(__COMPILER_HALT_OFFSET__);
__halt_compiler();

View file

@ -0,0 +1,12 @@
--TEST--
GH-18850: Repeated inclusion of file with __halt_compiler() triggers "Constant already defined" warning
--FILE--
<?php
require __DIR__ . '/gh18850.inc';
require __DIR__ . '/gh18850.inc';
?>
--EXPECT--
int(62)
int(62)

View file

@ -9566,7 +9566,11 @@ static void zend_compile_halt_compiler(zend_ast *ast) /* {{{ */
name = zend_mangle_property_name(const_name, sizeof(const_name) - 1,
ZSTR_VAL(filename), ZSTR_LEN(filename), 0);
zend_register_long_constant(ZSTR_VAL(name), ZSTR_LEN(name), offset, 0, 0);
/* Avoid repeated declaration of the __COMPILER_HALT_OFFSET__ constant in
* case this file was already included. */
if (!zend_hash_find(EG(zend_constants), name)) {
zend_register_long_constant(ZSTR_VAL(name), ZSTR_LEN(name), offset, 0, 0);
}
zend_string_release_ex(name, 0);
}
/* }}} */

View file

@ -38,8 +38,6 @@ include("phar://" . $filename);
--- Include 1 ---
hello world
--- Include 2 ---
Warning: Constant already defined in %s on line %d
hello world
--- After unlink ---