Skip to content

Commit d64424f

Browse files
committed
Merge branch 'upstream/PHP-7.4'
2 parents 8b69093 + e7fcc45 commit d64424f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+1347
-1694
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ PHP NEWS
88
(Nikita)
99
. Fixed bug #78066 (PHP eats the first byte of a program that comes from
1010
process substitution). (Nikita)
11+
. Fixed bug #52752 (Crash when lexing). (Nikita)
1112

1213
- Libxml:
1314
. Fixed bug #78279 (libxml_disable_entity_loader settings is shared between

UPGRADING

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ PHP 7.4 UPGRADE NOTES
3434
. Passing the result of a (non-reference) list() assignment by reference is
3535
consistently disallowed now. Previously this worked if the right hand side
3636
was a simple (CV) variable and did not occur as part of the list().
37+
. `<?php` at the end of the file (without trailing newline) will now be
38+
interpreted as an opening PHP tag. Previously it was interpreted either as
39+
`<? php` and resulted in a syntax error (with short_open_tag=1) or was
40+
interpreted as a literal `<?php` string (with short_open_tag=0).
3741

3842
- BCMath:
3943
. BCMath functions will now warn if a non well-formed number is passed, such

UPGRADING.INTERNALS

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,9 @@ PHP 7.4 INTERNALS UPGRADE NOTES
289289
- Removed unused check for dev/arandom and the HAVE_DEV_ARANDOM symbol.
290290
- Remove unused functions checks: HAVE_MBSINIT, HAVE_MEMPCPY, HAVE_SETPGID,
291291
HAVE_STRPNCPY, HAVE_STRTOULL, HAVE_VSNPRINTF, HAVE_CUSERID, HAVE_LRAND48,
292-
HAVE_RANDOM, HAVE_SRAND48, HAVE_SRANDOM, HAVE_STRDUP.
292+
HAVE_RANDOM, HAVE_SRAND48, HAVE_SRANDOM, HAVE_STRDUP, HAVE_GCVT,
293+
HAVE_ISASCII, HAVE_LINK, HAVE_LOCKF, HAVE_SOCKOPT, HAVE_SETVBUF, HAVE_SIN,
294+
HAVE_TEMPNAM.
293295
- Unused check for struct cmsghdr and symbol HAVE_CMSGHDR have been removed.
294296
- Unused ApplicationServices/ApplicationServices.h headers check and
295297
HAVE_APPLICATIONSERVICES_APPLICATIONSERVICES_H symbol have been removed.
@@ -301,6 +303,7 @@ PHP 7.4 INTERNALS UPGRADE NOTES
301303
c. Windows build system changes
302304

303305
. Visual Studio 2019 is utilized for the Windows builds
306+
. Removed unused defined symbol HAVE_LIBBIND.
304307

305308
========================
306309
3. Module changes

Zend/Zend.m4

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -306,10 +306,8 @@ AC_ARG_ENABLE([zend-signals],
306306
[ZEND_SIGNALS=$enableval],
307307
[ZEND_SIGNALS=yes])
308308
309-
AC_CHECK_FUNC(sigaction, [
310-
AC_DEFINE(HAVE_SIGACTION, 1, [Whether sigaction() is available])
311-
], [
312-
ZEND_SIGNALS=no
309+
AC_CHECK_FUNCS([sigaction], [], [
310+
ZEND_SIGNALS=no
313311
])
314312
if test "$ZEND_SIGNALS" = "yes"; then
315313
AC_DEFINE(ZEND_SIGNALS, 1, [Use zend signal handling])

Zend/tests/php_tag_only.inc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<?php

Zend/tests/php_tag_only.phpt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
--TEST--
2+
File with just a <?php tag should be valid
3+
--FILE_EXTERNAL--
4+
php_tag_only.inc
5+
--EXPECT--

Zend/zend_execute.c

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -364,16 +364,6 @@ static zend_always_inline zval *_get_zval_ptr_cv_deref_BP_VAR_R(uint32_t var EXE
364364
return ret;
365365
}
366366

367-
static zend_always_inline zval *_get_zval_ptr_cv_BP_VAR_UNSET(uint32_t var EXECUTE_DATA_DC)
368-
{
369-
zval *ret = EX_VAR(var);
370-
371-
if (UNEXPECTED(Z_TYPE_P(ret) == IS_UNDEF)) {
372-
return zval_undefined_cv(var EXECUTE_DATA_CC);
373-
}
374-
return ret;
375-
}
376-
377367
static zend_always_inline zval *_get_zval_ptr_cv_BP_VAR_IS(uint32_t var EXECUTE_DATA_DC)
378368
{
379369
zval *ret = EX_VAR(var);
@@ -1323,11 +1313,14 @@ static zend_always_inline int zend_binary_op(zval *ret, zval *op1, zval *op2 OPL
13231313
return zend_binary_ops[opcode - ZEND_ADD](ret, op1, op2);
13241314
}
13251315

1326-
static zend_never_inline void zend_binary_assign_op_obj_dim(zval *object, zval *property, zval *value OPLINE_DC EXECUTE_DATA_DC)
1316+
static zend_never_inline void zend_binary_assign_op_obj_dim(zval *object, zval *property OPLINE_DC EXECUTE_DATA_DC)
13271317
{
1318+
zend_free_op free_op_data1;
1319+
zval *value;
13281320
zval *z;
13291321
zval rv, res;
13301322

1323+
value = get_op_data_zval_ptr_r((opline+1)->op1_type, (opline+1)->op1, &free_op_data1);
13311324
if ((z = Z_OBJ_HT_P(object)->read_dimension(object, property, BP_VAR_R, &rv)) != NULL) {
13321325

13331326
if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) {
@@ -1355,6 +1348,7 @@ static zend_never_inline void zend_binary_assign_op_obj_dim(zval *object, zval *
13551348
ZVAL_NULL(EX_VAR(opline->result.var));
13561349
}
13571350
}
1351+
FREE_OP(free_op_data1);
13581352
}
13591353

13601354
static zend_never_inline void zend_binary_assign_op_typed_ref(zend_reference *ref, zval *value OPLINE_DC EXECUTE_DATA_DC)
@@ -2015,6 +2009,24 @@ static zend_never_inline ZEND_COLD void ZEND_FASTCALL zend_use_new_element_for_s
20152009
zend_throw_error(NULL, "[] operator not supported for strings");
20162010
}
20172011

2012+
static ZEND_COLD void zend_binary_assign_op_dim_slow(zval *container, zval *dim OPLINE_DC EXECUTE_DATA_DC)
2013+
{
2014+
zend_free_op free_op_data1;
2015+
2016+
if (UNEXPECTED(Z_TYPE_P(container) == IS_STRING)) {
2017+
if (opline->op2_type == IS_UNUSED) {
2018+
zend_use_new_element_for_string();
2019+
} else {
2020+
zend_check_string_offset(dim, BP_VAR_RW EXECUTE_DATA_CC);
2021+
zend_wrong_string_offset(EXECUTE_DATA_C);
2022+
}
2023+
} else if (EXPECTED(!Z_ISERROR_P(container))) {
2024+
zend_use_scalar_as_array();
2025+
}
2026+
get_op_data_zval_ptr_r((opline+1)->op1_type, (opline+1)->op1, &free_op_data1);
2027+
FREE_OP(free_op_data1);
2028+
}
2029+
20182030
static zend_never_inline zend_uchar slow_index_convert(const zval *dim, zend_value *value EXECUTE_DATA_DC)
20192031
{
20202032
switch (Z_TYPE_P(dim)) {
@@ -2739,6 +2751,12 @@ static zend_always_inline void zend_fetch_property_address(zval *result, zval *c
27392751
break;
27402752
}
27412753

2754+
if (container_op_type == IS_CV
2755+
&& type != BP_VAR_W
2756+
&& UNEXPECTED(Z_TYPE_P(container) == IS_UNDEF)) {
2757+
container = ZVAL_UNDEFINED_OP1();
2758+
}
2759+
27422760
/* this should modify object only if it's empty */
27432761
if (type == BP_VAR_UNSET) {
27442762
return;

Zend/zend_language_scanner.l

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -292,9 +292,6 @@ ZEND_API void zend_destroy_file_handle(zend_file_handle *file_handle)
292292
zend_llist_del_element(&CG(open_files), file_handle, (int (*)(void *, void *)) zend_compare_file_handles);
293293
/* zend_file_handle_dtor() operates on the copy, so we have to NULLify the original here */
294294
file_handle->opened_path = NULL;
295-
if (file_handle->free_filename) {
296-
file_handle->filename = NULL;
297-
}
298295
}
299296

300297
ZEND_API void zend_lex_tstring(zval *zv)
@@ -659,11 +656,7 @@ zend_op_array *compile_filename(int type, zval *filename)
659656
ZVAL_STR(&tmp, zval_get_string(filename));
660657
filename = &tmp;
661658
}
662-
file_handle.filename = Z_STRVAL_P(filename);
663-
file_handle.free_filename = 0;
664-
file_handle.type = ZEND_HANDLE_FILENAME;
665-
file_handle.opened_path = NULL;
666-
file_handle.handle.fp = NULL;
659+
zend_stream_init_filename(&file_handle, Z_STRVAL_P(filename));
667660

668661
retval = zend_compile_file(&file_handle, type);
669662
if (retval && file_handle.handle.stream.handle) {
@@ -789,10 +782,7 @@ int highlight_file(char *filename, zend_syntax_highlighter_ini *syntax_highlight
789782
zend_lex_state original_lex_state;
790783
zend_file_handle file_handle;
791784

792-
file_handle.type = ZEND_HANDLE_FILENAME;
793-
file_handle.filename = filename;
794-
file_handle.free_filename = 0;
795-
file_handle.opened_path = NULL;
785+
zend_stream_init_filename(&file_handle, filename);
796786
zend_save_lexical_state(&original_lex_state);
797787
if (open_file_for_scanning(&file_handle)==FAILURE) {
798788
zend_message_dispatcher(ZMSG_FAILED_HIGHLIGHT_FOPEN, filename);
@@ -2031,6 +2021,20 @@ string:
20312021
RETURN_OR_SKIP_TOKEN(T_OPEN_TAG);
20322022
}
20332023

2024+
<INITIAL>"<?php" {
2025+
/* Allow <?php followed by end of file. */
2026+
if (YYCURSOR == YYLIMIT) {
2027+
BEGIN(ST_IN_SCRIPTING);
2028+
RETURN_OR_SKIP_TOKEN(T_OPEN_TAG);
2029+
}
2030+
/* Degenerate case: <?phpX is interpreted as <? phpX with short tags. */
2031+
if (CG(short_tags)) {
2032+
yyless(2);
2033+
BEGIN(ST_IN_SCRIPTING);
2034+
RETURN_OR_SKIP_TOKEN(T_OPEN_TAG);
2035+
}
2036+
goto inline_char_handler;
2037+
}
20342038

20352039
<INITIAL>"<?" {
20362040
if (CG(short_tags)) {

0 commit comments

Comments
 (0)