com php-src: Fixed file-cache support (serialization/deserialization of zend_type): ext/opcache/zend_file_cache.c

[email protected] (Dmitry Stogov)
Newsgroups php.cvs
Message-ID <[email protected]>
Commit:    9276eb613c06331b9e3dfc90fcf3c30ca91d4b33
Author:    Dmitry Stogov <[email protected]>         Fri, 3 Mar 2017 12:26:49 +0300
Parents:   927d2d3608d19dbbb1868d8a9c8fa9ac709a9299
Branches:  master

Link:       http://git.php.net/?p=php-src.git;a=commitdiff;h=9276eb613c06331b9e3dfc90fcf3c30ca91d4b33

Log:
Fixed file-cache support (serialization/deserialization of zend_type)

Changed paths:
  M  ext/opcache/zend_file_cache.c


Diff:
diff --git a/ext/opcache/zend_file_cache.c b/ext/opcache/zend_file_cache.c
index 9e99dd6..2d5ebe6 100644
--- a/ext/opcache/zend_file_cache.c
+++ b/ext/opcache/zend_file_cache.c
@@ -437,14 +437,14 @@ static void zend_file_cache_serialize_op_array(zend_op_array            *op_arra
 					SERIALIZE_STR(p->name);
 				}
 				if (ZEND_TYPE_IS_CLASS(p->type)) {
+					zend_bool allow_null = ZEND_TYPE_ALLOW_NULL(p->type);
 					zend_string *type_name = ZEND_TYPE_NAME(p->type);
 
-					if (!IS_SERIALIZED(type_name)) {
-						zend_bool allow_null = ZEND_TYPE_ALLOW_NULL(p->type);
-
-						SERIALIZE_STR(type_name);
-						p->type = ZEND_TYPE_ENCODE_CLASS(type_name, allow_null);
-					}
+					SERIALIZE_STR(type_name);
+					p->type =
+						(Z_UL(1) << (sizeof(zend_type)*8-1)) | /* type is class */
+						(allow_null ? (Z_UL(1) << (sizeof(zend_type)*8-2)) : Z_UL(0)) | /* type allow null */
+						(zend_type)type_name;
 				}
 				p++;
 			}
@@ -1018,15 +1018,12 @@ static void zend_file_cache_unserialize_op_array(zend_op_array           *op_arr
 				if (!IS_UNSERIALIZED(p->name)) {
 					UNSERIALIZE_STR(p->name);
 				}
-				if (ZEND_TYPE_IS_CLASS(p->type)) {
-					zend_string *type_name = ZEND_TYPE_NAME(p->type);
-
-					if (!IS_UNSERIALIZED(type_name)) {
-						zend_bool allow_null = ZEND_TYPE_ALLOW_NULL(p->type);
+				if (p->type & (Z_UL(1) << (sizeof(zend_type)*8-1))) { /* type is class */
+					zend_bool allow_null = (p->type & (Z_UL(1) << (sizeof(zend_type)*8-2))) != 0; /* type allow null */
+					zend_string *type_name = (zend_string*)(p->type & ~(((Z_UL(1) << (sizeof(zend_type)*8-1))) | ((Z_UL(1) << (sizeof(zend_type)*8-2)))));
 
-						UNSERIALIZE_STR(type_name);
-						p->type = ZEND_TYPE_ENCODE_CLASS(type_name, allow_null);
-					}
+					UNSERIALIZE_STR(type_name);
+					p->type = ZEND_TYPE_ENCODE_CLASS(type_name, allow_null);
 				}
 				p++;
 			}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.