mirror of
https://github.com/php/php-src.git
synced 2024-12-12 11:23:53 +08:00
Return true for is_object() on Incomplete_Class
This commit is contained in:
parent
34824b70f8
commit
89f6377971
@ -22,6 +22,8 @@ PHP 7.1 UPGRADE NOTES
|
||||
- Core:
|
||||
. gettype() will now return "resource (closed)" instead of "unknown type" for
|
||||
closed resources.
|
||||
. is_object() will now return true for objects of class
|
||||
__PHP_Incomplete_Class.
|
||||
|
||||
========================================
|
||||
2. New Features
|
||||
|
@ -7769,14 +7769,7 @@ ZEND_VM_HANDLER(123, ZEND_TYPE_CHECK, CONST|TMP|VAR|CV, ANY, TYPE)
|
||||
SAVE_OPLINE();
|
||||
value = GET_OP1_ZVAL_PTR_DEREF(BP_VAR_R);
|
||||
if (EXPECTED(Z_TYPE_P(value) == opline->extended_value)) {
|
||||
if (OP1_TYPE != IS_CONST && UNEXPECTED(Z_TYPE_P(value) == IS_OBJECT)) {
|
||||
zend_class_entry *ce = Z_OBJCE_P(value);
|
||||
|
||||
if (EXPECTED(ZSTR_LEN(ce->name) != sizeof("__PHP_Incomplete_Class") - 1) ||
|
||||
EXPECTED(memcmp(ZSTR_VAL(ce->name), "__PHP_Incomplete_Class", sizeof("__PHP_Incomplete_Class") - 1) != 0)) {
|
||||
result = 1;
|
||||
}
|
||||
} else if (UNEXPECTED(Z_TYPE_P(value) == IS_RESOURCE)) {
|
||||
if (UNEXPECTED(Z_TYPE_P(value) == IS_RESOURCE)) {
|
||||
const char *type_name = zend_rsrc_list_get_rsrc_type(Z_RES_P(value));
|
||||
|
||||
if (EXPECTED(type_name != NULL)) {
|
||||
|
@ -4026,14 +4026,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_TYPE_CHECK_SPEC_CONST_HANDLER(
|
||||
SAVE_OPLINE();
|
||||
value = EX_CONSTANT(opline->op1);
|
||||
if (EXPECTED(Z_TYPE_P(value) == opline->extended_value)) {
|
||||
if (IS_CONST != IS_CONST && UNEXPECTED(Z_TYPE_P(value) == IS_OBJECT)) {
|
||||
zend_class_entry *ce = Z_OBJCE_P(value);
|
||||
|
||||
if (EXPECTED(ZSTR_LEN(ce->name) != sizeof("__PHP_Incomplete_Class") - 1) ||
|
||||
EXPECTED(memcmp(ZSTR_VAL(ce->name), "__PHP_Incomplete_Class", sizeof("__PHP_Incomplete_Class") - 1) != 0)) {
|
||||
result = 1;
|
||||
}
|
||||
} else if (UNEXPECTED(Z_TYPE_P(value) == IS_RESOURCE)) {
|
||||
if (UNEXPECTED(Z_TYPE_P(value) == IS_RESOURCE)) {
|
||||
const char *type_name = zend_rsrc_list_get_rsrc_type(Z_RES_P(value));
|
||||
|
||||
if (EXPECTED(type_name != NULL)) {
|
||||
@ -13036,14 +13029,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_TYPE_CHECK_SPEC_TMP_HANDLER(ZE
|
||||
SAVE_OPLINE();
|
||||
value = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1);
|
||||
if (EXPECTED(Z_TYPE_P(value) == opline->extended_value)) {
|
||||
if (IS_TMP_VAR != IS_CONST && UNEXPECTED(Z_TYPE_P(value) == IS_OBJECT)) {
|
||||
zend_class_entry *ce = Z_OBJCE_P(value);
|
||||
|
||||
if (EXPECTED(ZSTR_LEN(ce->name) != sizeof("__PHP_Incomplete_Class") - 1) ||
|
||||
EXPECTED(memcmp(ZSTR_VAL(ce->name), "__PHP_Incomplete_Class", sizeof("__PHP_Incomplete_Class") - 1) != 0)) {
|
||||
result = 1;
|
||||
}
|
||||
} else if (UNEXPECTED(Z_TYPE_P(value) == IS_RESOURCE)) {
|
||||
if (UNEXPECTED(Z_TYPE_P(value) == IS_RESOURCE)) {
|
||||
const char *type_name = zend_rsrc_list_get_rsrc_type(Z_RES_P(value));
|
||||
|
||||
if (EXPECTED(type_name != NULL)) {
|
||||
@ -16989,14 +16975,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_TYPE_CHECK_SPEC_VAR_HANDLER(ZE
|
||||
SAVE_OPLINE();
|
||||
value = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1);
|
||||
if (EXPECTED(Z_TYPE_P(value) == opline->extended_value)) {
|
||||
if (IS_VAR != IS_CONST && UNEXPECTED(Z_TYPE_P(value) == IS_OBJECT)) {
|
||||
zend_class_entry *ce = Z_OBJCE_P(value);
|
||||
|
||||
if (EXPECTED(ZSTR_LEN(ce->name) != sizeof("__PHP_Incomplete_Class") - 1) ||
|
||||
EXPECTED(memcmp(ZSTR_VAL(ce->name), "__PHP_Incomplete_Class", sizeof("__PHP_Incomplete_Class") - 1) != 0)) {
|
||||
result = 1;
|
||||
}
|
||||
} else if (UNEXPECTED(Z_TYPE_P(value) == IS_RESOURCE)) {
|
||||
if (UNEXPECTED(Z_TYPE_P(value) == IS_RESOURCE)) {
|
||||
const char *type_name = zend_rsrc_list_get_rsrc_type(Z_RES_P(value));
|
||||
|
||||
if (EXPECTED(type_name != NULL)) {
|
||||
@ -35796,14 +35775,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_TYPE_CHECK_SPEC_CV_HANDLER(ZEN
|
||||
SAVE_OPLINE();
|
||||
value = _get_zval_ptr_cv_deref_BP_VAR_R(execute_data, opline->op1.var);
|
||||
if (EXPECTED(Z_TYPE_P(value) == opline->extended_value)) {
|
||||
if (IS_CV != IS_CONST && UNEXPECTED(Z_TYPE_P(value) == IS_OBJECT)) {
|
||||
zend_class_entry *ce = Z_OBJCE_P(value);
|
||||
|
||||
if (EXPECTED(ZSTR_LEN(ce->name) != sizeof("__PHP_Incomplete_Class") - 1) ||
|
||||
EXPECTED(memcmp(ZSTR_VAL(ce->name), "__PHP_Incomplete_Class", sizeof("__PHP_Incomplete_Class") - 1) != 0)) {
|
||||
result = 1;
|
||||
}
|
||||
} else if (UNEXPECTED(Z_TYPE_P(value) == IS_RESOURCE)) {
|
||||
if (UNEXPECTED(Z_TYPE_P(value) == IS_RESOURCE)) {
|
||||
const char *type_name = zend_rsrc_list_get_rsrc_type(Z_RES_P(value));
|
||||
|
||||
if (EXPECTED(type_name != NULL)) {
|
||||
|
@ -450,9 +450,8 @@ static void place_essa_pis(
|
||||
if ((pi = add_pi(arena, op_array, dfg, ssa, j, bt, var))) {
|
||||
pi_type_mask(pi, mask_for_type_check(type));
|
||||
}
|
||||
if (type != IS_OBJECT && type != IS_RESOURCE) {
|
||||
/* is_object() and is_resource() may return false, even though the value is
|
||||
* an object/resource. */
|
||||
if (type != IS_RESOURCE) {
|
||||
/* is_resource() may return false for closed resources */
|
||||
if ((pi = add_pi(arena, op_array, dfg, ssa, j, bf, var))) {
|
||||
pi_not_type_mask(pi, mask_for_type_check(type));
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ object(__PHP_Incomplete_Class)#%d (2) {
|
||||
["p"]=>
|
||||
int(1)
|
||||
}
|
||||
bool(false)
|
||||
bool(true)
|
||||
|
||||
Notice: main(): The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition "C" of the object you are trying to operate on was loaded _before_ unserialize() gets called or provide a __autoload() function to load the class definition in %s on line 43
|
||||
NULL
|
||||
@ -117,4 +117,4 @@ Notice: main(): The script tried to execute a method or access a property of an
|
||||
Notice: main(): The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition "C" of the object you are trying to operate on was loaded _before_ unserialize() gets called or provide a __autoload() function to load the class definition in %s on line 57
|
||||
NULL
|
||||
|
||||
Fatal error: main(): The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition "C" of the object you are trying to operate on was loaded _before_ unserialize() gets called or provide a __autoload() function to load the class definition in %s on line 59
|
||||
Fatal error: main(): The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition "C" of the object you are trying to operate on was loaded _before_ unserialize() gets called or provide a __autoload() function to load the class definition in %s on line 59
|
||||
|
@ -217,13 +217,7 @@ static inline void php_is_type(INTERNAL_FUNCTION_PARAMETERS, int type)
|
||||
#endif
|
||||
|
||||
if (Z_TYPE_P(arg) == type) {
|
||||
if (type == IS_OBJECT) {
|
||||
zend_class_entry *ce = Z_OBJCE_P(arg);
|
||||
if (ZSTR_LEN(ce->name) == sizeof(INCOMPLETE_CLASS) - 1
|
||||
&& !memcmp(ZSTR_VAL(ce->name), INCOMPLETE_CLASS, sizeof(INCOMPLETE_CLASS) - 1)) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
} else if (type == IS_RESOURCE) {
|
||||
if (type == IS_RESOURCE) {
|
||||
const char *type_name = zend_rsrc_list_get_rsrc_type(Z_RES_P(arg));
|
||||
if (!type_name) {
|
||||
RETURN_FALSE;
|
||||
|
Loading…
Reference in New Issue
Block a user