com php-src: Return true for is_object() on Incomplet e_Class: UPGRADING Zend/zend_vm_def.h Zend/zend _vm_execute.h ext/opcache/Optimizer/zend_ssa.c
ex t/standard/tests/serialize/serialization_objects_005 .phpt ext/standard/type.c
| From: | Nikita Popov | Date: | Mon, 15 Aug 2016 21:13:09 +0000 |
| Subject: | com php-src: Return true for is_object() on Incomplet e_Class: UPGRADING Zend/zend_vm_def.h Zend/zend _vm_execute.h ext/opcache/Optimizer/zend_ssa.c ex t/standard/tests/serialize/serialization_objects_005 .phpt ext/standard/type.c |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-93795@lists.php.net to get a copy of this message | ||
Commit: 89f63779711f34d87c2464ae13965df868d6231f
Author: Nikita Popov <nikic@php.net> Fri, 22 Jul 2016 21:53:20 +0200
Parents: 34824b70f8e72b200d77957145bb61883b03322d
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=89f63779711f34d87c2464ae13965df868d6231f
Log:
Return true for is_object() on Incomplete_Class
Changed paths:
M UPGRADING
M Zend/zend_vm_def.h
M Zend/zend_vm_execute.h
M ext/opcache/Optimizer/zend_ssa.c
M ext/standard/tests/serialize/serialization_objects_005.phpt
M ext/standard/type.c
Diff:
diff --git a/UPGRADING b/UPGRADING
index 83942ba...c89f46d 100644
--- a/UPGRADING
+++ b/UPGRADING
@@ -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
diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h
index 1a52041..2498b79 100644
--- a/Zend/zend_vm_def.h
+++ b/Zend/zend_vm_def.h
@@ -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)) {
diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h
index 3d0bcf8..b9ce818 100644
--- a/Zend/zend_vm_execute.h
+++ b/Zend/zend_vm_execute.h
@@ -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)) {
diff --git a/ext/opcache/Optimizer/zend_ssa.c b/ext/opcache/Optimizer/zend_ssa.c
index 3d09c7e..8a115c0 100644
--- a/ext/opcache/Optimizer/zend_ssa.c
+++ b/ext/opcache/Optimizer/zend_ssa.c
@@ -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));
}
diff --git a/ext/standard/tests/serialize/serialization_objects_005.phpt
b/ext/standard/tests/serialize/serialization_objects_005.phpt
index 35b1593..9800168 100644
--- a/ext/standard/tests/serialize/serialization_objects_005.phpt
+++ b/ext/standard/tests/serialize/serialization_objects_005.phpt
@@ -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
\ No newline at end of file
+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
diff --git a/ext/standard/type.c b/ext/standard/type.c
index 59268c7..4e91b99 100644
--- a/ext/standard/type.c
+++ b/ext/standard/type.c
@@ -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;