Skip to content

Commit 2edf296

Browse files
committed
Merge pull request #1 from php/master
Merging upstream
2 parents a2c461d + b811885 commit 2edf296

Some content is hidden

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

42 files changed

+646
-122
lines changed

NEWS

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,25 @@
1-
PHP NEWS
1+
PHP NEWS
22
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
33
09 Jul 2015, PHP 7.0.0 Beta 1
44

55
- Core:
66
. Fixed bug #69768 (escapeshell*() doesn't cater to !). (cmb)
77

8+
- CLI server:
9+
. Fixed bug #69655 (php -S changes MKCALENDAR request method to MKCOL). (cmb)
10+
. Fixed bug #64878 (304 responses return Content-Type header). (cmb)
11+
12+
- COM:
13+
. Fixed bug #69939 (Casting object to bool returns false). (Kalle)
14+
815
- PCRE:
9-
. Fixed Bug #53823 (preg_replace: * qualifier on unicode replace garbles the
16+
. Fixed bug #53823 (preg_replace: * qualifier on unicode replace garbles the
1017
string). (cmb)
1118

19+
- OpenSSL:
20+
. Fixed bug #69882 (OpenSSL error "key values mismatch" after
21+
openssl_pkcs12_read with extra cert) (Tomasz Sawicki)
22+
1223
25 Jun 2015, PHP 7.0.0 Alpha 2
1324

1425
- Core:

README.RELEASE_PROCESS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ to upgrade.
266266

267267
8. Commit all the changes to their respective git repos
268268

269-
9. Please note down the md5, sha245 and the PGP signature (.asc). These *must* be
269+
9. Please note down the sha256 and the PGP signature (.asc). These *must* be
270270
included in the release mail.
271271
10. Wait an hour or two, then send a mail to [email protected],
272272
[email protected] and [email protected] with a text similar to

UPGRADING

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,11 @@ Other
610610
hardcoded value of 16. This limit is now removed and the number of pipes is
611611
effectively limited by the amount of memory available to PHP.
612612

613+
- array_column():
614+
The function now supports an array of objects as well as two-dimensional
615+
arrays. Only public properties are considered, and objects that make use of
616+
__get() for dynamic properties must also implement __isset().
617+
613618
========================================
614619
6. New Functions
615620
========================================
File renamed without changes.

Zend/tests/call_static_005.phpt

Lines changed: 0 additions & 21 deletions
This file was deleted.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--TEST--
2+
Closure must not leak during a dynamic call interrupted by an exception
3+
--FILE--
4+
<?php
5+
6+
(function() {
7+
$closure = function($foo) { var_dump($foo); };
8+
$closure(yield);
9+
})()->valid(); // start
10+
11+
?>
12+
==DONE==
13+
--EXPECT--
14+
==DONE==
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
--TEST--
2+
Indirect call with constants.
3+
--FILE--
4+
<?php
5+
6+
class Test
7+
{
8+
public static function method()
9+
{
10+
echo "Method called!\n";
11+
}
12+
}
13+
14+
['Test', 'method']();
15+
16+
'Test::method'();
17+
18+
(['Test', 'method'])();
19+
20+
('Test::method')();
21+
22+
?>
23+
--EXPECT--
24+
Method called!
25+
Method called!
26+
Method called!
27+
Method called!
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
--TEST--
2+
Indirect call with 'Class::method' syntax with class in namespace
3+
--FILE--
4+
<?php
5+
namespace TestNamespace
6+
{
7+
class TestClass
8+
{
9+
public static function staticMethod()
10+
{
11+
echo "Static method called!\n";
12+
}
13+
14+
public static function staticMethodWithArgs($arg1, $arg2, $arg3)
15+
{
16+
printf("Static method called with args: %s, %s, %s\n", $arg1, $arg2, $arg3);
17+
}
18+
}
19+
}
20+
21+
namespace CallNamespace
22+
{
23+
// Test basic call using Class::method syntax.
24+
$callback = 'TestNamespace\TestClass::staticMethod';
25+
$callback();
26+
27+
// Case should not matter.
28+
$callback = 'testnamespace\testclass::staticmethod';
29+
$callback();
30+
31+
$args = ['arg1', 'arg2', 'arg3'];
32+
$callback = 'TestNamespace\TestClass::staticMethodWithArgs';
33+
34+
// Test call with args.
35+
$callback($args[0], $args[1], $args[2]);
36+
37+
// Test call with splat operator.
38+
$callback(...$args);
39+
}
40+
?>
41+
--EXPECT--
42+
Static method called!
43+
Static method called!
44+
Static method called with args: arg1, arg2, arg3
45+
Static method called with args: arg1, arg2, arg3
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
--TEST--
2+
Indirect call with empty class and/or method name.
3+
--FILE--
4+
<?php
5+
class TestClass
6+
{
7+
public static function __callStatic($method, array $args)
8+
{
9+
var_dump($method);
10+
}
11+
}
12+
13+
// Test call using array syntax
14+
$callback = ['TestClass', ''];
15+
$callback();
16+
17+
// Test call using Class::method syntax.
18+
$callback = 'TestClass::';
19+
$callback();
20+
21+
// Test array syntax with empty class name
22+
$callback = ['', 'method'];
23+
try {
24+
$callback();
25+
} catch (Error $e) {
26+
echo $e->getMessage() . "\n";
27+
}
28+
29+
// Test Class::method syntax with empty class name
30+
$callback = '::method';
31+
try {
32+
$callback();
33+
} catch (Error $e) {
34+
echo $e->getMessage() . "\n";
35+
}
36+
37+
// Test array syntax with empty class and method name
38+
$callback = ['', ''];
39+
try {
40+
$callback();
41+
} catch (Error $e) {
42+
echo $e->getMessage() . "\n";
43+
}
44+
45+
// Test Class::method syntax with empty class and method name
46+
$callback = '::';
47+
try {
48+
$callback();
49+
} catch (Error $e) {
50+
echo $e->getMessage() . "\n";
51+
}
52+
53+
// Test string ending in single colon
54+
$callback = 'Class:';
55+
try {
56+
$callback();
57+
} catch (Error $e) {
58+
echo $e->getMessage() . "\n";
59+
}
60+
61+
// Test string beginning in single colon
62+
$callback = ':method';
63+
try {
64+
$callback();
65+
} catch (Error $e) {
66+
echo $e->getMessage() . "\n";
67+
}
68+
69+
// Test single colon
70+
$callback = ':';
71+
try {
72+
$callback();
73+
} catch (Error $e) {
74+
echo $e->getMessage() . "\n";
75+
}
76+
?>
77+
--EXPECT--
78+
string(0) ""
79+
string(0) ""
80+
Class '' not found
81+
Class '' not found
82+
Class '' not found
83+
Class '' not found
84+
Call to undefined function Class:()
85+
Call to undefined function :method()
86+
Call to undefined function :()

Zend/zend_alloc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ ZEND_API size_t ZEND_FASTCALL _zend_mem_block_size(void *ptr ZEND_FILE_LINE_DC Z
8484
#include "zend_alloc_sizes.h"
8585

8686
/* _emalloc() & _efree() specialization */
87-
#if !ZEND_DEBUG && !defined(_WIN32)
87+
#if !ZEND_DEBUG && defined(HAVE_BUILTIN_CONSTANT_P)
8888

8989
# define _ZEND_BIN_ALLOCATOR_DEF(_num, _size, _elements, _pages, x, y) \
9090
ZEND_API void* ZEND_FASTCALL _emalloc_ ## _size(void) ZEND_ATTRIBUTE_MALLOC;

Zend/zend_compile.c

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2866,16 +2866,30 @@ void zend_compile_dynamic_call(znode *result, znode *name_node, zend_ast *args_a
28662866
{
28672867
zend_op *opline = get_next_op(CG(active_op_array));
28682868
if (name_node->op_type == IS_CONST && Z_TYPE(name_node->u.constant) == IS_STRING) {
2869-
opline->opcode = ZEND_INIT_FCALL_BY_NAME;
2870-
opline->op2_type = IS_CONST;
2871-
opline->op2.constant = zend_add_func_name_literal(CG(active_op_array),
2872-
Z_STR(name_node->u.constant));
2873-
zend_alloc_cache_slot(opline->op2.constant);
2869+
const char *colon;
2870+
zend_string *str = Z_STR(name_node->u.constant);
2871+
if ((colon = zend_memrchr(str->val, ':', str->len)) != NULL && colon > str->val && *(colon - 1) == ':') {
2872+
zend_string *class = zend_string_init(str->val, colon - str->val - 1, 0);
2873+
zend_string *method = zend_string_init(colon + 1, str->len - (colon - str->val) - 1, 0);
2874+
opline->opcode = ZEND_INIT_STATIC_METHOD_CALL;
2875+
opline->op1_type = IS_CONST;
2876+
opline->op1.constant = zend_add_class_name_literal(CG(active_op_array), class);
2877+
opline->op2_type = IS_CONST;
2878+
opline->op2.constant = zend_add_func_name_literal(CG(active_op_array), method);
2879+
zend_alloc_cache_slot(opline->op2.constant);
2880+
zval_ptr_dtor(&name_node->u.constant);
2881+
} else {
2882+
opline->opcode = ZEND_INIT_FCALL_BY_NAME;
2883+
SET_UNUSED(opline->op1);
2884+
opline->op2_type = IS_CONST;
2885+
opline->op2.constant = zend_add_func_name_literal(CG(active_op_array), str);
2886+
zend_alloc_cache_slot(opline->op2.constant);
2887+
}
28742888
} else {
28752889
opline->opcode = ZEND_INIT_DYNAMIC_CALL;
2890+
SET_UNUSED(opline->op1);
28762891
SET_NODE(opline->op2, name_node);
28772892
}
2878-
SET_UNUSED(opline->op1);
28792893

28802894
zend_compile_call_common(result, args_ast, NULL);
28812895
}

Zend/zend_execute.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2486,6 +2486,9 @@ static zend_always_inline void i_cleanup_unfinished_execution(zend_execute_data
24862486
}
24872487
OBJ_RELEASE(Z_OBJ(call->This));
24882488
}
2489+
if (call->func->common.fn_flags & ZEND_ACC_CLOSURE) {
2490+
zend_object_release((zend_object *) call->func->common.prototype);
2491+
}
24892492
if (call->func->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE) {
24902493
zend_string_release(call->func->common.function_name);
24912494
zend_free_trampoline(call->func);

Zend/zend_execute.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ static zend_always_inline zval* zend_assign_to_variable(zval *variable_ptr, zval
5858
{
5959
zend_refcounted *ref = NULL;
6060

61-
if ((value_type & (IS_VAR|IS_CV)) && Z_ISREF_P(value)) {
61+
if (ZEND_CONST_COND(value_type & (IS_VAR|IS_CV), 1) && Z_ISREF_P(value)) {
6262
ref = Z_COUNTED_P(value);
6363
value = Z_REFVAL_P(value);
6464
}
@@ -78,7 +78,7 @@ static zend_always_inline zval* zend_assign_to_variable(zval *variable_ptr, zval
7878
Z_OBJ_HANDLER_P(variable_ptr, set)(variable_ptr, value);
7979
return variable_ptr;
8080
}
81-
if ((value_type & (IS_VAR|IS_CV)) && variable_ptr == value) {
81+
if (ZEND_CONST_COND(value_type & (IS_VAR|IS_CV), 1) && variable_ptr == value) {
8282
return variable_ptr;
8383
}
8484
garbage = Z_COUNTED_P(variable_ptr);
@@ -93,7 +93,7 @@ static zend_always_inline zval* zend_assign_to_variable(zval *variable_ptr, zval
9393
if (UNEXPECTED(Z_OPT_REFCOUNTED_P(variable_ptr))) {
9494
Z_ADDREF_P(variable_ptr);
9595
}
96-
} else if (/* value_type == IS_VAR && */ UNEXPECTED(ref)) {
96+
} else if (ZEND_CONST_COND(value_type == IS_VAR, 1) && UNEXPECTED(ref)) {
9797
if (UNEXPECTED(--GC_REFCOUNT(ref) == 0)) {
9898
efree_size(ref, sizeof(zend_reference));
9999
} else if (Z_OPT_REFCOUNTED_P(variable_ptr)) {
@@ -122,7 +122,7 @@ static zend_always_inline zval* zend_assign_to_variable(zval *variable_ptr, zval
122122
if (UNEXPECTED(Z_OPT_REFCOUNTED_P(variable_ptr))) {
123123
Z_ADDREF_P(variable_ptr);
124124
}
125-
} else if (/* value_type == IS_VAR && */ UNEXPECTED(ref)) {
125+
} else if (ZEND_CONST_COND(value_type == IS_VAR, 1) && UNEXPECTED(ref)) {
126126
if (UNEXPECTED(--GC_REFCOUNT(ref) == 0)) {
127127
efree_size(ref, sizeof(zend_reference));
128128
} else if (Z_OPT_REFCOUNTED_P(variable_ptr)) {

Zend/zend_portability.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,18 @@ char *alloca();
246246
# define HAVE_ATTRIBUTE_WEAK
247247
#endif
248248

249+
#if ZEND_GCC_VERSION >= 3001 || __has_builtin(__builtin_constant_p)
250+
# define HAVE_BUILTIN_CONSTANT_P
251+
#endif
252+
253+
#ifdef HAVE_BUILTIN_CONSTANT_P
254+
# define ZEND_CONST_COND(_condition, _default) \
255+
(__builtin_constant_p(_condition) ? (_condition) : (_default))
256+
#else
257+
# define ZEND_CONST_COND(_condition, _default) \
258+
(_default)
259+
#endif
260+
249261
#if ZEND_DEBUG
250262
# define zend_always_inline inline
251263
# define zend_never_inline

Zend/zend_vm_def.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3237,12 +3237,6 @@ ZEND_VM_C_LABEL(try_function_name):
32373237
size_t cname_length = colon - Z_STRVAL_P(function_name) - 1;
32383238
size_t mname_length = Z_STRLEN_P(function_name) - cname_length - (sizeof("::") - 1);
32393239

3240-
if (!mname_length) {
3241-
zend_error(E_EXCEPTION | E_ERROR, "Call to undefined function %s()", Z_STRVAL_P(function_name));
3242-
FREE_OP2();
3243-
HANDLE_EXCEPTION();
3244-
}
3245-
32463240
lcname = zend_string_init(Z_STRVAL_P(function_name), cname_length, 0);
32473241

32483242
called_scope = zend_fetch_class_by_name(lcname, NULL, ZEND_FETCH_CLASS_DEFAULT | ZEND_FETCH_CLASS_EXCEPTION);

0 commit comments

Comments
 (0)