Skip to content
forked from php/php-src

Commit 86e41ca

Browse files
authored
Merge pull request #7 from php/master
sync master
2 parents ee22aa4 + 1079622 commit 86e41ca

Some content is hidden

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

55 files changed

+1020
-678
lines changed

NEWS

+11
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@ PHP NEWS
22
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
33
?? ??? ????, PHP 8.0.0rc2
44

5+
- Curl:
6+
. Fixed bug #80121 (Null pointer deref if CurlHandle directly instantiated).
7+
(Nikita)
8+
9+
- SPL:
10+
. Fixed bug #65387 (Circular references in SPL iterators are not garbage
11+
collected). (Nikita)
12+
13+
- Standard:
14+
. Fixed bug #64060 (lstat_stat_variation7.phpt fails on certain file systems).
15+
(M. Voelker, cmb)
516

617
01 Oct 2020, PHP 8.0.0rc1
718

UPGRADING

+5
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ PHP 8.0 UPGRADE NOTES
2727
. Methods with the same name as the class are no longer interpreted as
2828
constructors. The __construct() method should be used instead.
2929
. Removed ability to call non-static methods statically.
30+
Thus `is_callable` will fail when checking for a non-static method with a
31+
classname (must check with an object instance).
3032
. Removed (unset) cast.
3133
. Removed track_errors ini directive. This means that $php_errormsg is no
3234
longer available. The error_get_last() function may be used instead.
@@ -608,6 +610,9 @@ PHP 8.0 UPGRADE NOTES
608610
. Calling crypt() without an explicit salt is no longer supported. If you
609611
would like to produce a strong hash with an auto-generated salt, use
610612
password_hash() instead.
613+
. substr(), mb_substr(), iconv_substr() and grapheme_substr() now consistently
614+
clamp out-of-bounds offsets to the string boundary. Previously, false was
615+
returned instead of the empty string in some cases.
611616

612617
- Sysvmsg:
613618
. msg_get_queue() will now return an SysvMessageQueue object rather than a

Zend/tests/div_by_zero_in_static.phpt

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--TEST--
2+
Division by zero in static
3+
--FILE--
4+
<?php
5+
static $a = 1/0;
6+
?>
7+
--EXPECTF--
8+
Fatal error: Uncaught DivisionByZeroError: Division by zero in %s:%d
9+
Stack trace:
10+
#0 {main}
11+
thrown in %s on line %d
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--TEST--
2+
Try to instantiate all classes without arguments
3+
--FILE--
4+
<?php
5+
6+
foreach (get_declared_classes() as $class) {
7+
try {
8+
new $class;
9+
} catch (Throwable) {}
10+
}
11+
12+
?>
13+
===DONE===
14+
--EXPECT--
15+
===DONE===

Zend/zend_operators.c

+12-11
Original file line numberDiff line numberDiff line change
@@ -1253,7 +1253,9 @@ ZEND_API zend_result ZEND_FASTCALL pow_function(zval *result, zval *op1, zval *o
12531253
}
12541254
/* }}} */
12551255

1256-
static zend_result ZEND_FASTCALL div_function_base(zval *result, zval *op1, zval *op2) /* {{{ */
1256+
/* Returns SUCCESS/FAILURE/TYPES_NOT_HANDLED */
1257+
#define TYPES_NOT_HANDLED 1
1258+
static int ZEND_FASTCALL div_function_base(zval *result, zval *op1, zval *op2) /* {{{ */
12571259
{
12581260
zend_uchar type_pair = TYPE_PAIR(Z_TYPE_P(op1), Z_TYPE_P(op2));
12591261

@@ -1290,23 +1292,25 @@ static zend_result ZEND_FASTCALL div_function_base(zval *result, zval *op1, zval
12901292
ZVAL_DOUBLE(result, (double)Z_LVAL_P(op1) / Z_DVAL_P(op2));
12911293
return SUCCESS;
12921294
} else {
1293-
return FAILURE;
1295+
return TYPES_NOT_HANDLED;
12941296
}
12951297
division_by_0:
12961298
if (result != op1) {
12971299
ZVAL_UNDEF(result);
12981300
}
12991301
zend_throw_error(zend_ce_division_by_zero_error, "Division by zero");
1300-
return SUCCESS;
1302+
return FAILURE;
13011303
}
13021304
/* }}} */
13031305

13041306
ZEND_API zend_result ZEND_FASTCALL div_function(zval *result, zval *op1, zval *op2) /* {{{ */
13051307
{
13061308
ZVAL_DEREF(op1);
13071309
ZVAL_DEREF(op2);
1308-
if (div_function_base(result, op1, op2) == SUCCESS) {
1309-
return SUCCESS;
1310+
1311+
int retval = div_function_base(result, op1, op2);
1312+
if (retval != TYPES_NOT_HANDLED) {
1313+
return retval;
13101314
}
13111315

13121316
ZEND_TRY_BINARY_OBJECT_OPERATION(ZEND_DIV);
@@ -1325,12 +1329,9 @@ ZEND_API zend_result ZEND_FASTCALL div_function(zval *result, zval *op1, zval *o
13251329
zval_ptr_dtor(result);
13261330
}
13271331

1328-
if (div_function_base(result, &op1_copy, &op2_copy) == SUCCESS) {
1329-
return SUCCESS;
1330-
}
1331-
1332-
ZEND_ASSERT(0 && "Operation must succeed");
1333-
return FAILURE;
1332+
retval = div_function_base(result, &op1_copy, &op2_copy);
1333+
ZEND_ASSERT(retval != TYPES_NOT_HANDLED && "Types should be handled");
1334+
return retval;
13341335
}
13351336
/* }}} */
13361337

0 commit comments

Comments
 (0)