mirror of
https://github.com/php/php-src.git
synced 2025-08-15 13:38:49 +02:00
Merge branch '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
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.4: Fix "Constant already defined" warning with repeated inclusion of file with __halt_compiler()
This commit is contained in:
commit
9c754baa99
5 changed files with 26 additions and 3 deletions
4
NEWS
4
NEWS
|
@ -2,6 +2,10 @@ PHP NEWS
|
|||
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||
?? ??? ????, PHP 8.5.0beta2
|
||||
|
||||
- Core:
|
||||
. Fixed bug GH-18850 (Repeated inclusion of file with __halt_compiler()
|
||||
triggers "Constant already defined" warning). (ilutov)
|
||||
|
||||
- ODBC:
|
||||
. Remove ODBCVER and assume ODBC 3.5. (Calvin Buckley)
|
||||
|
||||
|
|
5
Zend/tests/constants/gh18850.inc
Normal file
5
Zend/tests/constants/gh18850.inc
Normal file
|
@ -0,0 +1,5 @@
|
|||
<?php
|
||||
|
||||
var_dump(__COMPILER_HALT_OFFSET__);
|
||||
|
||||
__halt_compiler();
|
12
Zend/tests/constants/gh18850.phpt
Normal file
12
Zend/tests/constants/gh18850.phpt
Normal 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)
|
|
@ -9752,7 +9752,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);
|
||||
}
|
||||
/* }}} */
|
||||
|
|
|
@ -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 ---
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue