Skip to content

Commit 860f0ca

Browse files
committed
Merge remote-tracking branch 'origin/PHP-5.6' into str_size_and_int64_56_backport
* origin/PHP-5.6: (46 commits) Fix wrong lenght size Bug #51096 - Remove unnecessary ? for first/last day of Moved streams related functions to xp_ssl.c Remove duplicate NEWS Update NEWS Update NEWS Update NEWS BFN BFN Fixed bug #67715 (php-milter does not build and crashes randomly). We need to turn off any strict mode here for this warning to show up Disable restrictions regarding arrays in constants at run-time. For the discussion around it, see the thread on the mailing list: http://www.mail-archive.com/internals@lists.php.net/msg68245.html Revert "Fix bug #67064 in a BC safe way" Updated NEWS for #67693 Updated NEWS for #67693 Fixed bug #67693 - incorrect push to the empty array add missing entry to NEWS add missing entries to NEWS add NEWS block for the next RC NEWS entry for #67713 ... Conflicts: Zend/zend_language_parser.y ext/odbc/php_odbc.c ext/openssl/openssl.c ext/spl/spl_directory.c ext/spl/spl_iterators.c ext/sqlite3/sqlite3.c ext/standard/array.c
2 parents be8f557 + f5deb18 commit 860f0ca

40 files changed

+12143
-11711
lines changed

NEWS

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
11
PHP NEWS
22
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
3-
?? ??? 2014, PHP 5.6.0 Release Candidate 3
3+
?? ??? 2014, PHP 5.6.0 Release Candidate 4
4+
5+
- Core:
6+
. Fixed bug #67693 (incorrect push to the empty array). (Tjerk)
7+
. Removed inconsistency regarding behaviour of array in constants at
8+
run-time. (Bob)
9+
10+
- Milter:
11+
. Fixed bug #67715 (php-milter does not build and crashes randomly). (Mike)
12+
13+
- SPL:
14+
. Revert fix for bug #67064 (BC issues). (Bob)
15+
16+
31 Jul 2014, PHP 5.6.0 Release Candidate 3
417

518
- Core:
619
. Fixed bug #67497 (eval with parse error causes segmentation fault in
@@ -12,6 +25,9 @@ PHP NEWS
1225
(Laruence, Dmitry)
1326
. Implemented FR #34407 (ucwords and Title Case). (Tjerk)
1427

28+
- COM:
29+
. Fixed missing type checks in com_event_sink (Yussuf Khalil, Stas).
30+
1531
- CLI server:
1632
. Fixed bug #66830 (Empty header causes PHP built-in web server to hang).
1733
(Adam)
@@ -32,20 +48,37 @@ PHP NEWS
3248
- pgsql:
3349
. Fixed bug #67555 (Cannot build against libpq 7.3). (Adam)
3450

51+
- ODBC:
52+
. Fixed bug #60616 (odbc_fetch_into returns junk at end of multi-byte char
53+
fields). (Keyur Govande)
54+
3555
- OpenSSL:
56+
. Fixed missing type checks in OpenSSL options (Yussuf Khalil, Stas).
3657
. Fixed bug #67609 (TLS connections fail behind HTTP proxy). (Daniel Lowrey)
3758
. Fixed broken build against OpenSSL older than 0.9.8 where ECDH unavailable.
3859
(Lior Kaplan)
60+
. Fixed bug #67666 (Subject altNames doesn't support wildcard matching). (Tjerk)
3961

4062
- Phar:
4163
. Fixed bug #67587 (Redirection loop on nginx with FPM). (Christian Weiske)
4264

65+
- readline:
66+
. Fixed bug #55496 (Interactive mode doesn't force a newline before the
67+
prompt). (Bob, Johannes)
68+
. Fixed bug #67496 (Save command history when exiting interactive shell
69+
with control-c). (Dmitry Saprykin, Johannes)
70+
71+
- Reflection:
72+
. Implemented FR #67713 (loosen the restrictions on
73+
ReflectionClass::newInstanceWithoutConstructor()). (Ferenc)
74+
4375
- SPL:
4476
. Fixed bug #67539 (ArrayIterator use-after-free due to object change during
4577
sorting). (research at insighti dot org, Laruence)
4678
. Fixed bug #67538 (SPL Iterators use-after-free). (CVE-2014-4670) (Laruence)
4779

4880
- Session:
81+
. Fixed missing type checks in php_session_create_id (Yussuf Khalil, Stas).
4982
. Fixed bug #66827 (Session raises E_NOTICE when session name variable is array).
5083
(Yasuo)
5184

Zend/tests/constant_expressions_arrays.phpt

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class foo {
2222

2323
var_dump(foo::bar);
2424

25-
var_dump(a); // Eventually allow that later with array dereferencing of constants
25+
var_dump(a, a[0], a[2], a[2][1], a[3]);
2626

2727
?>
2828
--EXPECTF--
@@ -32,4 +32,35 @@ int(1)
3232
int(4)
3333
int(1)
3434

35-
Fatal error: Arrays are not allowed in constants at run-time in %s on line %d
35+
Notice: Undefined offset: 3 in %s on line %d
36+
array(3) {
37+
[0]=>
38+
int(1)
39+
[1]=>
40+
int(2)
41+
[2]=>
42+
array(2) {
43+
[0]=>
44+
int(3)
45+
[1]=>
46+
array(1) {
47+
[0]=>
48+
int(4)
49+
}
50+
}
51+
}
52+
int(1)
53+
array(2) {
54+
[0]=>
55+
int(3)
56+
[1]=>
57+
array(1) {
58+
[0]=>
59+
int(4)
60+
}
61+
}
62+
array(1) {
63+
[0]=>
64+
int(4)
65+
}
66+
NULL

Zend/tests/constant_expressions_self_referencing_array.phpt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
--TEST--
22
Self-referencing constant expression (part of a constant AST)
3-
--XFAIL--
4-
Not yet fixed, to be fixed for PHP 5.6
53
--FILE--
64
<?php
75
class A {

Zend/tests/errmsg_040.phpt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,12 @@ var_dump(test::TEST);
1212
echo "Done\n";
1313
?>
1414
--EXPECTF--
15-
Fatal error: Arrays are not allowed in constants at run-time in %s on line %d
15+
array(3) {
16+
[0]=>
17+
int(1)
18+
[1]=>
19+
int(2)
20+
[2]=>
21+
int(3)
22+
}
23+
Done

Zend/tests/ns_059.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ const C = array();
77
var_dump(C);
88
?>
99
--EXPECTF--
10-
Fatal error: Arrays are not allowed in constants at run-time in %sns_059.php on line 4
11-
10+
array(0) {
11+
}

Zend/zend_ast.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -251,10 +251,19 @@ ZEND_API void zend_ast_evaluate(zval *result, zend_ast *ast, zend_class_entry *s
251251
zval_dtor(&op2);
252252
break;
253253
case ZEND_CONST:
254-
*result = *ast->u.val;
255-
zval_copy_ctor(result);
256-
if (IS_CONSTANT_TYPE(Z_TYPE_P(result))) {
257-
zval_update_constant_ex(&result, 1, scope TSRMLS_CC);
254+
/* class constants may be updated in-place */
255+
if (scope) {
256+
if (IS_CONSTANT_TYPE(Z_TYPE_P(ast->u.val))) {
257+
zval_update_constant_ex(&ast->u.val, 1, scope TSRMLS_CC);
258+
}
259+
*result = *ast->u.val;
260+
zval_copy_ctor(result);
261+
} else {
262+
*result = *ast->u.val;
263+
zval_copy_ctor(result);
264+
if (IS_CONSTANT_TYPE(Z_TYPE_P(result))) {
265+
zval_update_constant_ex(&result, 1, scope TSRMLS_CC);
266+
}
258267
}
259268
break;
260269
case ZEND_BOOL_AND:

Zend/zend_language_parser.y

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -865,13 +865,16 @@ yield_expr:
865865
;
866866

867867
combined_scalar_offset:
868-
combined_scalar '[' dim_offset ']' { zend_do_begin_variable_parse(TSRMLS_C); fetch_array_dim(&$$, &$1, &$3 TSRMLS_CC); }
869-
| combined_scalar_offset '[' dim_offset ']' { fetch_array_dim(&$$, &$1, &$3 TSRMLS_CC); }
870-
| T_CONSTANT_ENCAPSED_STRING '[' dim_offset ']' { $1.EA = 0; zend_do_begin_variable_parse(TSRMLS_C); fetch_array_dim(&$$, &$1, &$3 TSRMLS_CC); }
868+
combined_scalar '[' dim_offset ']' { zend_do_begin_variable_parse(TSRMLS_C); fetch_array_dim(&$$, &$1, &$3 TSRMLS_CC); }
869+
| combined_scalar_offset '[' dim_offset ']' { fetch_array_dim(&$$, &$1, &$3 TSRMLS_CC); }
870+
| T_CONSTANT_ENCAPSED_STRING '[' dim_offset ']' { $1.EA = 0; zend_do_begin_variable_parse(TSRMLS_C); fetch_array_dim(&$$, &$1, &$3 TSRMLS_CC); }
871+
| general_constant '[' dim_offset ']' { zend_do_begin_variable_parse(TSRMLS_C); fetch_array_dim(&$$, &$1, &$3 TSRMLS_CC); }
872+
;
871873

872874
combined_scalar:
873-
T_ARRAY '(' array_pair_list ')' { $$ = $3; }
874-
| '[' array_pair_list ']' { $$ = $2; }
875+
T_ARRAY '(' array_pair_list ')' { $$ = $3; }
876+
| '[' array_pair_list ']' { $$ = $2; }
877+
;
875878

876879
function:
877880
T_FUNCTION { $$.u.op.opline_num = CG(zend_lineno); }
@@ -1038,20 +1041,22 @@ static_operation:
10381041
| '(' static_scalar_value ')' { $$ = $2; }
10391042
;
10401043

1041-
1042-
scalar:
1043-
T_STRING_VARNAME { $$ = $1; }
1044-
| class_name_scalar { $$ = $1; }
1045-
| class_constant { $$ = $1; }
1044+
general_constant:
1045+
class_constant { $$ = $1; }
10461046
| namespace_name { zend_do_fetch_constant(&$$, NULL, &$1, ZEND_RT, 1 TSRMLS_CC); }
10471047
| T_NAMESPACE T_NS_SEPARATOR namespace_name { $$.op_type = IS_CONST; ZVAL_EMPTY_STRING(&$$.u.constant); zend_do_build_namespace_name(&$$, &$$, &$3 TSRMLS_CC); $3 = $$; zend_do_fetch_constant(&$$, NULL, &$3, ZEND_RT, 0 TSRMLS_CC); }
10481048
| T_NS_SEPARATOR namespace_name { char *tmp = estrndup(Z_STRVAL($2.u.constant), Z_STRSIZE($2.u.constant)+1); memcpy(&(tmp[1]), Z_STRVAL($2.u.constant), Z_STRSIZE($2.u.constant)+1); tmp[0] = '\\'; efree(Z_STRVAL($2.u.constant)); Z_STRVAL($2.u.constant) = tmp; ++Z_STRSIZE($2.u.constant); zend_do_fetch_constant(&$$, NULL, &$2, ZEND_RT, 0 TSRMLS_CC); }
1049-
| common_scalar { $$ = $1; }
1050-
| '"' encaps_list '"' { $$ = $2; }
1051-
| T_START_HEREDOC encaps_list T_END_HEREDOC { $$ = $2; }
1052-
| T_CLASS_C { if (Z_TYPE($1.u.constant) == IS_CONSTANT) {zend_do_fetch_constant(&$$, NULL, &$1, ZEND_RT, 1 TSRMLS_CC);} else {$$ = $1;} }
10531049
;
10541050

1051+
scalar:
1052+
T_STRING_VARNAME { $$ = $1; }
1053+
| general_constant { $$ = $1; }
1054+
| class_name_scalar { $$ = $1; }
1055+
| common_scalar { $$ = $1; }
1056+
| '"' encaps_list '"' { $$ = $2; }
1057+
| T_START_HEREDOC encaps_list T_END_HEREDOC { $$ = $2; }
1058+
| T_CLASS_C { if (Z_TYPE($1.u.constant) == IS_CONSTANT) {zend_do_fetch_constant(&$$, NULL, &$1, ZEND_RT, 1 TSRMLS_CC);} else {$$ = $1;} }
1059+
;
10551060

10561061
static_array_pair_list:
10571062
/* empty */ { $$.op_type = IS_CONST; INIT_PZVAL(&$$.u.constant); array_init(&$$.u.constant); $$.u.ast = zend_ast_create_constant(&$$.u.constant); }

Zend/zend_vm_def.h

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3772,9 +3772,6 @@ ZEND_VM_HANDLER(99, ZEND_FETCH_CONSTANT, VAR|CONST|UNUSED, CONST)
37723772
}
37733773
}
37743774
constant_fetch_end:
3775-
if (Z_TYPE(EX_T(opline->result.var).tmp_var) == IS_ARRAY) {
3776-
zend_error_noreturn(E_ERROR, "Arrays are not allowed in constants at run-time");
3777-
}
37783775
CHECK_EXCEPTION();
37793776
ZEND_VM_NEXT_OPCODE();
37803777
}
@@ -5387,7 +5384,16 @@ ZEND_VM_HANDLER(143, ZEND_DECLARE_CONST, CONST, CONST)
53875384
c.value = *tmp_ptr;
53885385
} else {
53895386
INIT_PZVAL_COPY(&c.value, val);
5390-
zval_copy_ctor(&c.value);
5387+
if (Z_TYPE(c.value) == IS_ARRAY) {
5388+
HashTable *ht;
5389+
5390+
ALLOC_HASHTABLE(ht);
5391+
zend_hash_init(ht, zend_hash_num_elements(Z_ARRVAL(c.value)), NULL, ZVAL_PTR_DTOR, 0);
5392+
zend_hash_copy(ht, Z_ARRVAL(c.value), (copy_ctor_func_t) zval_deep_copy, NULL, sizeof(zval *));
5393+
Z_ARRVAL(c.value) = ht;
5394+
} else {
5395+
zval_copy_ctor(&c.value);
5396+
}
53915397
}
53925398
c.flags = CONST_CS; /* non persistent, case sensetive */
53935399
c.name = str_strndup(Z_STRVAL_P(name), Z_STRSIZE_P(name));

Zend/zend_vm_execute.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4036,9 +4036,6 @@ static int ZEND_FASTCALL ZEND_FETCH_CONSTANT_SPEC_CONST_CONST_HANDLER(ZEND_OPCO
40364036
}
40374037
}
40384038
constant_fetch_end:
4039-
if (Z_TYPE(EX_T(opline->result.var).tmp_var) == IS_ARRAY) {
4040-
zend_error_noreturn(E_ERROR, "Arrays are not allowed in constants at run-time");
4041-
}
40424039
CHECK_EXCEPTION();
40434040
ZEND_VM_NEXT_OPCODE();
40444041
}
@@ -4323,7 +4320,16 @@ static int ZEND_FASTCALL ZEND_DECLARE_CONST_SPEC_CONST_CONST_HANDLER(ZEND_OPCOD
43234320
c.value = *tmp_ptr;
43244321
} else {
43254322
INIT_PZVAL_COPY(&c.value, val);
4326-
zval_copy_ctor(&c.value);
4323+
if (Z_TYPE(c.value) == IS_ARRAY) {
4324+
HashTable *ht;
4325+
4326+
ALLOC_HASHTABLE(ht);
4327+
zend_hash_init(ht, zend_hash_num_elements(Z_ARRVAL(c.value)), NULL, ZVAL_PTR_DTOR, 0);
4328+
zend_hash_copy(ht, Z_ARRVAL(c.value), (copy_ctor_func_t) zval_deep_copy, NULL, sizeof(zval *));
4329+
Z_ARRVAL(c.value) = ht;
4330+
} else {
4331+
zval_copy_ctor(&c.value);
4332+
}
43274333
}
43284334
c.flags = CONST_CS; /* non persistent, case sensetive */
43294335
c.name = str_strndup(Z_STRVAL_P(name), Z_STRSIZE_P(name));
@@ -15992,9 +15998,6 @@ static int ZEND_FASTCALL ZEND_FETCH_CONSTANT_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE
1599215998
}
1599315999
}
1599416000
constant_fetch_end:
15995-
if (Z_TYPE(EX_T(opline->result.var).tmp_var) == IS_ARRAY) {
15996-
zend_error_noreturn(E_ERROR, "Arrays are not allowed in constants at run-time");
15997-
}
1599816001
CHECK_EXCEPTION();
1599916002
ZEND_VM_NEXT_OPCODE();
1600016003
}
@@ -25604,9 +25607,6 @@ static int ZEND_FASTCALL ZEND_FETCH_CONSTANT_SPEC_UNUSED_CONST_HANDLER(ZEND_OPC
2560425607
}
2560525608
}
2560625609
constant_fetch_end:
25607-
if (Z_TYPE(EX_T(opline->result.var).tmp_var) == IS_ARRAY) {
25608-
zend_error_noreturn(E_ERROR, "Arrays are not allowed in constants at run-time");
25609-
}
2561025610
CHECK_EXCEPTION();
2561125611
ZEND_VM_NEXT_OPCODE();
2561225612
}

ext/com_dotnet/com_com.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -698,9 +698,9 @@ PHP_FUNCTION(com_event_sink)
698698
/* 0 => typelibname, 1 => dispname */
699699
zval **tmp;
700700

701-
if (zend_hash_index_find(Z_ARRVAL_P(sink), 0, (void**)&tmp) == SUCCESS)
701+
if (zend_hash_index_find(Z_ARRVAL_P(sink), 0, (void**)&tmp) == SUCCESS && Z_TYPE_PP(tmp) == IS_STRING)
702702
typelibname = Z_STRVAL_PP(tmp);
703-
if (zend_hash_index_find(Z_ARRVAL_P(sink), 1, (void**)&tmp) == SUCCESS)
703+
if (zend_hash_index_find(Z_ARRVAL_P(sink), 1, (void**)&tmp) == SUCCESS && Z_TYPE_PP(tmp) == IS_STRING)
704704
dispname = Z_STRVAL_PP(tmp);
705705
} else if (sink != NULL) {
706706
convert_to_string(sink);

0 commit comments

Comments
 (0)