-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Drop usages of E_RECOVERABLE_ERROR #6106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
97cf236
e543540
7902c43
9dc6bb2
b915dfa
8b9235c
bfb44ac
3166d6a
d0acc40
5a0ff89
b076737
de6c99e
ff15543
cf4b750
e84c542
566752c
0764e59
1c141ff
ad2457c
0ed06d7
750ea90
8592167
8ee2f61
62f17c1
32d6566
401230f
9c47de0
70c2e4c
a0091b9
e657b50
16e8867
dc804dc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1423,7 +1423,7 @@ ZEND_API zend_result ZEND_FASTCALL mod_function(zval *result, zval *op1, zval *o | |
|
||
ZEND_API zend_result ZEND_FASTCALL boolean_xor_function(zval *result, zval *op1, zval *op2) /* {{{ */ | ||
{ | ||
int op1_val, op2_val; | ||
bool op1_val, op2_val; | ||
|
||
do { | ||
if (Z_TYPE_P(op1) == IS_FALSE) { | ||
|
@@ -1443,6 +1443,10 @@ ZEND_API zend_result ZEND_FASTCALL boolean_xor_function(zval *result, zval *op1, | |
} | ||
ZEND_TRY_BINARY_OP1_OBJECT_OPERATION(ZEND_BOOL_XOR); | ||
op1_val = zval_is_true(op1); | ||
if (UNEXPECTED(EG(exception))) { | ||
ZVAL_UNDEF(result); | ||
return FAILURE; | ||
} | ||
} | ||
} while (0); | ||
do { | ||
|
@@ -1463,6 +1467,10 @@ ZEND_API zend_result ZEND_FASTCALL boolean_xor_function(zval *result, zval *op1, | |
} | ||
ZEND_TRY_BINARY_OP2_OBJECT_OPERATION(ZEND_BOOL_XOR); | ||
op2_val = zval_is_true(op2); | ||
if (UNEXPECTED(EG(exception))) { | ||
ZVAL_UNDEF(result); | ||
return FAILURE; | ||
} | ||
} | ||
} while (0); | ||
|
||
|
@@ -1478,6 +1486,7 @@ ZEND_API zend_result ZEND_FASTCALL boolean_not_function(zval *result, zval *op1) | |
} else if (EXPECTED(Z_TYPE_P(op1) == IS_TRUE)) { | ||
ZVAL_FALSE(result); | ||
} else { | ||
bool not; | ||
if (Z_ISREF_P(op1)) { | ||
op1 = Z_REFVAL_P(op1); | ||
if (Z_TYPE_P(op1) < IS_TRUE) { | ||
|
@@ -1490,7 +1499,12 @@ ZEND_API zend_result ZEND_FASTCALL boolean_not_function(zval *result, zval *op1) | |
} | ||
ZEND_TRY_UNARY_OBJECT_OPERATION(ZEND_BOOL_NOT); | ||
|
||
ZVAL_BOOL(result, !zval_is_true(op1)); | ||
not = !zval_is_true(op1); | ||
if (UNEXPECTED(EG(exception))) { | ||
ZVAL_UNDEF(result); | ||
return FAILURE; | ||
} | ||
ZVAL_BOOL(result, not); | ||
} | ||
return SUCCESS; | ||
} | ||
|
@@ -2214,13 +2228,29 @@ ZEND_API int ZEND_FASTCALL zend_compare(zval *op1, zval *op2) /* {{{ */ | |
|
||
if (!converted) { | ||
if (Z_TYPE_P(op1) < IS_TRUE) { | ||
return zval_is_true(op2) ? -1 : 0; | ||
bool is_true = zval_is_true(op2); | ||
if (UNEXPECTED(EG(exception))) { | ||
return 1; | ||
} | ||
return is_true ? -1 : 0; | ||
} else if (Z_TYPE_P(op1) == IS_TRUE) { | ||
return zval_is_true(op2) ? 0 : 1; | ||
bool is_true = zval_is_true(op2); | ||
if (UNEXPECTED(EG(exception))) { | ||
return 1; | ||
} | ||
return is_true ? 0 : 1; | ||
} else if (Z_TYPE_P(op2) < IS_TRUE) { | ||
return zval_is_true(op1) ? 1 : 0; | ||
bool is_true = zval_is_true(op1); | ||
if (UNEXPECTED(EG(exception))) { | ||
return 1; | ||
} | ||
return is_true ? 1 : 0; | ||
} else if (Z_TYPE_P(op2) == IS_TRUE) { | ||
return zval_is_true(op1) ? 0 : -1; | ||
bool is_true = zval_is_true(op1); | ||
if (UNEXPECTED(EG(exception))) { | ||
return 1; | ||
} | ||
return is_true ? 0 : -1; | ||
} else { | ||
op1 = _zendi_convert_scalar_to_number_silent(op1, &op1_copy); | ||
op2 = _zendi_convert_scalar_to_number_silent(op2, &op2_copy); | ||
|
@@ -2594,6 +2624,7 @@ ZEND_API zend_result ZEND_FASTCALL decrement_function(zval *op1) /* {{{ */ | |
} | ||
/* }}} */ | ||
|
||
/* TODO make JIT compatible with a bool return */ | ||
ZEND_API int ZEND_FASTCALL zend_is_true(zval *op) /* {{{ */ | ||
{ | ||
return (int) i_zend_is_true(op); | ||
|
@@ -2607,7 +2638,7 @@ ZEND_API bool ZEND_FASTCALL zend_object_is_true(zval *op) /* {{{ */ | |
if (zobj->handlers->cast_object(zobj, &tmp, _IS_BOOL) == SUCCESS) { | ||
return Z_TYPE(tmp) == IS_TRUE; | ||
} | ||
zend_error(E_RECOVERABLE_ERROR, "Object of class %s could not be converted to bool", ZSTR_VAL(zobj->ce->name)); | ||
zend_type_error("Object of class %s could not be converted to bool", ZSTR_VAL(zobj->ce->name)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is generally fine, but we will need to perform an exception-safety audit on all users for zend_is_true/zval_is_true. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure how feasible it is do perform this before next Tuesday when RC1 gets tagged as there does seems to be a couple of crucial usages (zend_compare, OpCache) looking at: https://heap.space/search?project=php-src&refs=zval_is_true and https://heap.space/search?project=php-src&refs=zend_is_true There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think I've checked all of them but I'm very unsure about how to go about it with some cases. |
||
return false; | ||
} | ||
/* }}} */ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Objects definitely can't occur in this context.