1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Merge branch 'PHP-8.3' into PHP-8.4

* 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
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 ---