Skip to content

Commit ee704bf

Browse files
committed
Merge branch 'master' of https://github.com/php/php-src
2 parents 003c91b + 6e664f6 commit ee704bf

Some content is hidden

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

43 files changed

+516
-95
lines changed

NEWS

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,16 @@ Core:
66
. Fixed bug #62210 (Exceptions can leak temporary variables). (Dmitry, Bob)
77
. Added void return type. (Andrea)
88

9-
Standard
9+
Hash:
10+
. Added SHA3 fixed mode algorithms (224, 256, 384, and 512 bit). (Sara)
11+
12+
PDO_Firebird:
13+
. Fixed bug #60052 (Integer returned as a 64bit integer on X64_86). (Mariuz)
14+
15+
Standard:
1016
. Implemented FR #55716 (Add an option to pass a custom stream context to
1117
get_headers()). (Ferenc)
1218
. Implemented FR #69359 (Provide a way to fetch the current environment
1319
variables). (Ferenc)
1420

15-
Hash
16-
. Added SHA3 fixed mode algorithms (224, 256, 384, and 512 bit). (Sara)
17-
1821
<<< NOTE: Insert NEWS from last stable release here prior to actual release! >>>

README.RELEASE_PROCESS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ team (Bjori) on hand.
3131

3232
6. Verify the tags to be extra sure everything was tagged properly.
3333

34-
7. Moving extensions from/to PECL requires write acces to the destination.
34+
7. Moving extensions from/to PECL requires write access to the destination.
3535
Most developers should have this.
3636

3737
Moving extensions from php-src to PECL

Zend/tests/bug26166.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ catch (Exception $e) {
6868
--EXPECTF--
6969
Hello World!
7070
===NONE===
71-
string(56) "Method NoneTest::__toString() must return a string value"
71+
string(%d) "Method NoneTest::__toString() must return a string value"
7272
===THROW===
7373

74-
Fatal error: Method ErrorTest::__toString() must not throw an exception in %sbug26166.php on line %d
74+
Fatal error: Method ErrorTest::__toString() must not throw an exception, caught Exception: This is an error! in %sbug26166.php on line %d

Zend/tests/bug60909_2.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class Bad {
1414
$bad = new Bad();
1515
echo "$bad";
1616
--EXPECTF--
17-
Fatal error: Method Bad::__toString() must not throw an exception in %sbug60909_2.php on line 0
17+
Fatal error: Method Bad::__toString() must not throw an exception, caught Exception: Oops, I cannot do this in %sbug60909_2.php on line %d
1818

1919

2020
!!!shutdown!!!

Zend/tests/bug70967.phpt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--TEST--
2+
Bug #70967 (Weird error handling for __toString when Error is thrown)
3+
--FILE--
4+
<?php
5+
class A {
6+
public function __toString() {
7+
undefined_function();
8+
}
9+
}
10+
11+
echo (new A);
12+
?>
13+
--EXPECTF--
14+
Fatal error: Method A::__toString() must not throw an exception, caught Error: Call to undefined function undefined_function() in %sbug70967.php on line %d

Zend/tests/bug70987.phpt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--TEST--
2+
Bug #70987 (static::class within Closure::call() causes segfault)
3+
--FILE--
4+
<?php
5+
6+
class foo {}
7+
$bar = function () {
8+
return static::class;
9+
};
10+
11+
var_dump($bar->call(new foo));
12+
13+
?>
14+
--EXPECTF--
15+
string(3) "foo"

Zend/tests/bug70997.phpt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
--TEST--
2+
Bug #70997 (When using parentClass:: instead of parent::, static context changed)
3+
--FILE--
4+
<?php
5+
class A {
6+
const TEST = false;
7+
8+
public function test()
9+
{
10+
var_dump(static::TEST);
11+
}
12+
}
13+
14+
class B extends A {
15+
const TEST = true;
16+
17+
public function test()
18+
{
19+
A::test();
20+
}
21+
}
22+
23+
$b = new B;
24+
$b->test();
25+
--EXPECT--
26+
bool(true)

Zend/tests/generators/bug71013.phpt

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
--TEST--
2+
Bug #71013 (Incorrect exception handler with yield from)
3+
--FILE--
4+
<?php
5+
6+
class FooBar implements Iterator {
7+
function __construct() { echo "Constructing new FooBar\n"; }
8+
function __destruct() { echo "Destructing FooBar\n"; }
9+
function current () { throw new Exception; }
10+
function key () { return 0; }
11+
function next () {}
12+
function rewind () {}
13+
function valid () { return true; }
14+
}
15+
16+
function foo() {
17+
try {
18+
$f = new FooBar;
19+
yield from $f;
20+
} catch (Exception $e) {
21+
echo "[foo()] Caught Exception\n";
22+
}
23+
}
24+
25+
function bar() {
26+
echo "Starting bar()\n";
27+
$x = foo();
28+
try {
29+
var_dump($x->current());
30+
} catch (Exception $e) {
31+
echo "[bar()] Caught Exception\n";
32+
}
33+
echo "Unsetting \$x\n";
34+
unset($x);
35+
echo "Finishing bar()\n";
36+
}
37+
38+
bar();
39+
40+
?>
41+
--EXPECT--
42+
Starting bar()
43+
Constructing new FooBar
44+
[foo()] Caught Exception
45+
Destructing FooBar
46+
NULL
47+
Unsetting $x
48+
Finishing bar()
49+

Zend/tests/ns_068.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ echo __NAMESPACE__ . "\n";
1111
===DONE===
1212
--EXPECTF--
1313

14-
Fatal error: Namespace declaration statement has to be the very first statement in the script in %sns_068.php on line %d
14+
Fatal error: Namespace declaration statement has to be the very first statement or after any declare call in the script in %sns_068.php on line %d

Zend/tests/ns_083.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ echo "ok\n";
1111
}
1212
?>
1313
--EXPECTF--
14-
Fatal error: Namespace declaration statement has to be the very first statement in the script in %s on line %d
14+
Fatal error: Namespace declaration statement has to be the very first statement or after any declare call in the script in %sns_083.php on line %d

Zend/zend_alloc.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -506,9 +506,9 @@ static void zend_mm_munmap(void *addr, size_t size)
506506
/* number of trailing set (1) bits */
507507
static zend_always_inline int zend_mm_bitset_nts(zend_mm_bitset bitset)
508508
{
509-
#if (defined(__GNUC__) || __has_builtin(__builtin_ctzl)) && SIZEOF_ZEND_LONG == SIZEOF_LONG
509+
#if (defined(__GNUC__) || __has_builtin(__builtin_ctzl)) && SIZEOF_ZEND_LONG == SIZEOF_LONG && defined(PHP_HAVE_BUILTIN_CTZL)
510510
return __builtin_ctzl(~bitset);
511-
#elif defined(__GNUC__) || __has_builtin(__builtin_ctzll)
511+
#elif (defined(__GNUC__) || __has_builtin(__builtin_ctzll)) && defined(PHP_HAVE_BUILTIN_CTZLL)
512512
return __builtin_ctzll(~bitset);
513513
#elif defined(_WIN32)
514514
unsigned long index;
@@ -545,9 +545,9 @@ static zend_always_inline int zend_mm_bitset_nts(zend_mm_bitset bitset)
545545
/* number of trailing zero bits (0x01 -> 1; 0x40 -> 6; 0x00 -> LEN) */
546546
static zend_always_inline int zend_mm_bitset_ntz(zend_mm_bitset bitset)
547547
{
548-
#if (defined(__GNUC__) || __has_builtin(__builtin_ctzl)) && SIZEOF_ZEND_LONG == SIZEOF_LONG
548+
#if (defined(__GNUC__) || __has_builtin(__builtin_ctzl)) && SIZEOF_ZEND_LONG == SIZEOF_LONG && defined(PHP_HAVE_BUILTIN_CTZL)
549549
return __builtin_ctzl(bitset);
550-
#elif defined(__GNUC__) || __has_builtin(__builtin_ctzll)
550+
#elif (defined(__GNUC__) || __has_builtin(__builtin_ctzll)) && defined(PHP_HAVE_BUILTIN_CTZLL)
551551
return __builtin_ctzll(bitset);
552552
#elif defined(_WIN32)
553553
unsigned long index;
@@ -1161,7 +1161,7 @@ static zend_always_inline void zend_mm_free_large(zend_mm_heap *heap, zend_mm_ch
11611161
/* higher set bit number (0->N/A, 1->1, 2->2, 4->3, 8->4, 127->7, 128->8 etc) */
11621162
static zend_always_inline int zend_mm_small_size_to_bit(int size)
11631163
{
1164-
#if defined(__GNUC__) || __has_builtin(__builtin_clz)
1164+
#if (defined(__GNUC__) || __has_builtin(__builtin_clz)) && defined(PHP_HAVE_BUILTIN_CLZ)
11651165
return (__builtin_clz(size) ^ 0x1f) + 1;
11661166
#elif defined(_WIN32)
11671167
unsigned long index;

Zend/zend_closures.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ ZEND_METHOD(Closure, call)
150150
fci.param_count = my_param_count;
151151
fci.object = fci_cache.object = newobj;
152152
fci_cache.initialized = 1;
153+
fci_cache.called_scope = Z_OBJCE_P(newthis);
153154

154155
if (fci_cache.function_handler->common.fn_flags & ZEND_ACC_GENERATOR) {
155156
zval new_closure;

Zend/zend_compile.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5843,7 +5843,7 @@ void zend_compile_namespace(zend_ast *ast) /* {{{ */
58435843
}
58445844
if (num > 0) {
58455845
zend_error_noreturn(E_COMPILE_ERROR, "Namespace declaration statement has to be "
5846-
"the very first statement in the script");
5846+
"the very first statement or after any declare call in the script");
58475847
}
58485848
}
58495849

Zend/zend_generators.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ static int zend_generator_get_next_delegated_value(zend_generator *generator) /*
573573
if (iter->index++ > 0) {
574574
iter->funcs->move_forward(iter);
575575
if (UNEXPECTED(EG(exception) != NULL)) {
576-
goto failure;
576+
goto exception;
577577
}
578578
}
579579

@@ -583,7 +583,9 @@ static int zend_generator_get_next_delegated_value(zend_generator *generator) /*
583583
}
584584

585585
value = iter->funcs->get_current_data(iter);
586-
if (UNEXPECTED(EG(exception) != NULL || !value)) {
586+
if (UNEXPECTED(EG(exception) != NULL)) {
587+
goto exception;
588+
} else if (UNEXPECTED(!value)) {
587589
goto failure;
588590
}
589591

@@ -595,14 +597,21 @@ static int zend_generator_get_next_delegated_value(zend_generator *generator) /*
595597
iter->funcs->get_current_key(iter, &generator->key);
596598
if (UNEXPECTED(EG(exception) != NULL)) {
597599
ZVAL_UNDEF(&generator->key);
598-
goto failure;
600+
goto exception;
599601
}
600602
} else {
601603
ZVAL_LONG(&generator->key, iter->index);
602604
}
603605
}
604606
return SUCCESS;
605607

608+
exception: {
609+
zend_execute_data *ex = EG(current_execute_data);
610+
EG(current_execute_data) = generator->execute_data;
611+
zend_throw_exception_internal(NULL);
612+
EG(current_execute_data) = ex;
613+
}
614+
606615
failure:
607616
zval_ptr_dtor(&generator->values);
608617
ZVAL_UNDEF(&generator->values);

Zend/zend_hash.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ static uint32_t zend_always_inline zend_hash_check_size(uint32_t nSize)
112112
rather than using an undefined bis scan result. */
113113
return nSize;
114114
}
115-
#elif defined(__GNUC__) || __has_builtin(__builtin_clz)
115+
#elif (defined(__GNUC__) || __has_builtin(__builtin_clz)) && defined(PHP_HAVE_BUILTIN_CLZ)
116116
return 0x2 << (__builtin_clz(nSize - 1) ^ 0x1f);
117117
#else
118118
nSize -= 1;

Zend/zend_object_handlers.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1526,9 +1526,18 @@ ZEND_API int zend_std_cast_object_tostring(zval *readobj, zval *writeobj, int ty
15261526
if (ce->__tostring &&
15271527
(zend_call_method_with_0_params(readobj, ce, &ce->__tostring, "__tostring", &retval) || EG(exception))) {
15281528
if (UNEXPECTED(EG(exception) != NULL)) {
1529+
zval *msg, ex, rv;
15291530
zval_ptr_dtor(&retval);
1531+
ZVAL_OBJ(&ex, EG(exception));
15301532
EG(exception) = NULL;
1531-
zend_error_noreturn(E_ERROR, "Method %s::__toString() must not throw an exception", ZSTR_VAL(ce->name));
1533+
msg = zend_read_property(Z_OBJCE(ex), &ex, "message", sizeof("message") - 1, 1, &rv);
1534+
if (UNEXPECTED(Z_TYPE_P(msg) != IS_STRING)) {
1535+
ZVAL_EMPTY_STRING(&rv);
1536+
msg = &rv;
1537+
}
1538+
zend_error_noreturn(E_ERROR,
1539+
"Method %s::__toString() must not throw an exception, caught %s: %s",
1540+
ZSTR_VAL(ce->name), ZSTR_VAL(Z_OBJCE(ex)->name), Z_STRVAL_P(msg));
15321541
return FAILURE;
15331542
}
15341543
if (EXPECTED(Z_TYPE(retval) == IS_STRING)) {

Zend/zend_vm_def.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3189,8 +3189,8 @@ ZEND_VM_HANDLER(113, ZEND_INIT_STATIC_METHOD_CALL, UNUSED|CONST|VAR, CONST|TMPVA
31893189
if (!(fbc->common.fn_flags & ZEND_ACC_STATIC)) {
31903190
if (Z_OBJ(EX(This)) && instanceof_function(Z_OBJCE(EX(This)), ce)) {
31913191
object = Z_OBJ(EX(This));
3192-
}
3193-
if (!object) {
3192+
ce = object->ce;
3193+
} else {
31943194
if (fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) {
31953195
/* Allowed for PHP 4 compatibility. */
31963196
zend_error(

Zend/zend_vm_execute.h

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5658,8 +5658,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_C
56585658
if (!(fbc->common.fn_flags & ZEND_ACC_STATIC)) {
56595659
if (Z_OBJ(EX(This)) && instanceof_function(Z_OBJCE(EX(This)), ce)) {
56605660
object = Z_OBJ(EX(This));
5661-
}
5662-
if (!object) {
5661+
ce = object->ce;
5662+
} else {
56635663
if (fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) {
56645664
/* Allowed for PHP 4 compatibility. */
56655665
zend_error(
@@ -7547,8 +7547,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_C
75477547
if (!(fbc->common.fn_flags & ZEND_ACC_STATIC)) {
75487548
if (Z_OBJ(EX(This)) && instanceof_function(Z_OBJCE(EX(This)), ce)) {
75497549
object = Z_OBJ(EX(This));
7550-
}
7551-
if (!object) {
7550+
ce = object->ce;
7551+
} else {
75527552
if (fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) {
75537553
/* Allowed for PHP 4 compatibility. */
75547554
zend_error(
@@ -9359,8 +9359,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_C
93599359
if (!(fbc->common.fn_flags & ZEND_ACC_STATIC)) {
93609360
if (Z_OBJ(EX(This)) && instanceof_function(Z_OBJCE(EX(This)), ce)) {
93619361
object = Z_OBJ(EX(This));
9362-
}
9363-
if (!object) {
9362+
ce = object->ce;
9363+
} else {
93649364
if (fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) {
93659365
/* Allowed for PHP 4 compatibility. */
93669366
zend_error(
@@ -11173,8 +11173,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_C
1117311173
if (!(fbc->common.fn_flags & ZEND_ACC_STATIC)) {
1117411174
if (Z_OBJ(EX(This)) && instanceof_function(Z_OBJCE(EX(This)), ce)) {
1117511175
object = Z_OBJ(EX(This));
11176-
}
11177-
if (!object) {
11176+
ce = object->ce;
11177+
} else {
1117811178
if (fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) {
1117911179
/* Allowed for PHP 4 compatibility. */
1118011180
zend_error(
@@ -17504,8 +17504,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_V
1750417504
if (!(fbc->common.fn_flags & ZEND_ACC_STATIC)) {
1750517505
if (Z_OBJ(EX(This)) && instanceof_function(Z_OBJCE(EX(This)), ce)) {
1750617506
object = Z_OBJ(EX(This));
17507-
}
17508-
if (!object) {
17507+
ce = object->ce;
17508+
} else {
1750917509
if (fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) {
1751017510
/* Allowed for PHP 4 compatibility. */
1751117511
zend_error(
@@ -19110,8 +19110,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_V
1911019110
if (!(fbc->common.fn_flags & ZEND_ACC_STATIC)) {
1911119111
if (Z_OBJ(EX(This)) && instanceof_function(Z_OBJCE(EX(This)), ce)) {
1911219112
object = Z_OBJ(EX(This));
19113-
}
19114-
if (!object) {
19113+
ce = object->ce;
19114+
} else {
1911519115
if (fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) {
1911619116
/* Allowed for PHP 4 compatibility. */
1911719117
zend_error(
@@ -20735,8 +20735,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_V
2073520735
if (!(fbc->common.fn_flags & ZEND_ACC_STATIC)) {
2073620736
if (Z_OBJ(EX(This)) && instanceof_function(Z_OBJCE(EX(This)), ce)) {
2073720737
object = Z_OBJ(EX(This));
20738-
}
20739-
if (!object) {
20738+
ce = object->ce;
20739+
} else {
2074020740
if (fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) {
2074120741
/* Allowed for PHP 4 compatibility. */
2074220742
zend_error(
@@ -22311,8 +22311,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_V
2231122311
if (!(fbc->common.fn_flags & ZEND_ACC_STATIC)) {
2231222312
if (Z_OBJ(EX(This)) && instanceof_function(Z_OBJCE(EX(This)), ce)) {
2231322313
object = Z_OBJ(EX(This));
22314-
}
22315-
if (!object) {
22314+
ce = object->ce;
22315+
} else {
2231622316
if (fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) {
2231722317
/* Allowed for PHP 4 compatibility. */
2231822318
zend_error(

0 commit comments

Comments
 (0)