mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Merge branch 'PHP-8.4'
* PHP-8.4: Fix "Constant already defined" warning with repeated inclusion of file with __halt_compiler()
This commit is contained in:
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 ---
|
||||
|
||||
|
||||
Reference in New Issue
Block a user