cvs: php4 /ext/standard php_var.h var.c /ext/wddx wddx.c
| From: | Thies C. Arntzen | Date: | Wed, 21 Jun 2000 18:22:22 +0000 |
| Subject: | cvs: php4 /ext/standard php_var.h var.c /ext/wddx wddx.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-386@lists.php.net to get a copy of this message | ||
thies Wed Jun 21 11:22:22 2000 EDT
Modified files:
/php4/ext/standard php_var.h var.c
/php4/ext/wddx wddx.c
Log:
unserialize() and wddx_deserialize() now create an empty class if they enconter
a class which's code is yet unknown. this makes sessionized data retain the
class name of objects even if you visited pages that don't have the classes
code available.
Index: php4/ext/standard/php_var.h
diff -u php4/ext/standard/php_var.h:1.1 php4/ext/standard/php_var.h:1.2
--- php4/ext/standard/php_var.h:1.1 Sat Dec 4 11:16:04 1999
+++ php4/ext/standard/php_var.h Wed Jun 21 11:22:22 2000
@@ -39,4 +39,6 @@
void php_var_serialize(pval *buf, pval **struc);
int php_var_unserialize(pval **rval, const char **p, const char *max);
+PHPAPI zend_class_entry *php_create_empty_class(char *class_name,int len);
+
#endif /* _PHPVAR_H */
Index: php4/ext/standard/var.c
diff -u php4/ext/standard/var.c:1.65 php4/ext/standard/var.c:1.66
--- php4/ext/standard/var.c:1.65 Sun Jun 18 03:25:39 2000
+++ php4/ext/standard/var.c Wed Jun 21 11:22:22 2000
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: var.c,v 1.65 2000/06/18 10:25:39 thies Exp $ */
+/* $Id: var.c,v 1.66 2000/06/21 18:22:22 thies Exp $ */
/* {{{ includes
@@ -33,6 +33,30 @@
#define COMMON ((*struc)->is_ref?"&":"")
/* }}} */
+
+PHPAPI zend_class_entry *php_create_empty_class(char *class_name,int len)
+{
+ zend_class_entry nclass,*nclassp;
+
+ CLS_FETCH();
+
+ memset(&nclass,0,sizeof(zend_class_entry));
+
+ nclass.name = estrdup(class_name);
+ nclass.name_length = len;
+ nclass.type = ZEND_USER_CLASS;
+ nclass.refcount = (int *) emalloc(sizeof(int));
+ *nclass.refcount = 1;
+ nclass.constants_updated = 0;
+
+ zend_hash_init(&nclass.function_table, 10, NULL, ZEND_FUNCTION_DTOR, 0);
+ zend_hash_init(&nclass.default_properties, 10, NULL, ZVAL_PTR_DTOR, 0);
+
+ zend_hash_update(CG(class_table), nclass.name, nclass.name_length + 1, &nclass,
sizeof(zend_class_entry), (void **) &nclassp);
+
+ return nclassp;
+}
+
/* {{{ php_var_dump */
static int php_array_element_dump(zval **zv, int num_args, va_list args, zend_hash_key *hash_key)
@@ -451,8 +475,11 @@
(*p) += i;
if (zend_hash_find(EG(class_table), class_name, i+1, (void **) &ce)==FAILURE) {
+ ce = php_create_empty_class(class_name,i);
+ /*
php_error(E_NOTICE, "Unserializing non-existant class: %s! No methods will be
available!", class_name);
ce = &zend_standard_class_def;
+ */
}
efree(class_name);
Index: php4/ext/wddx/wddx.c
diff -u php4/ext/wddx/wddx.c:1.45 php4/ext/wddx/wddx.c:1.46
--- php4/ext/wddx/wddx.c:1.45 Mon Jun 19 07:04:57 2000
+++ php4/ext/wddx/wddx.c Wed Jun 21 11:22:22 2000
@@ -27,13 +27,15 @@
+----------------------------------------------------------------------+
*/
-/* $Id: wddx.c,v 1.45 2000/06/19 14:04:57 andrei Exp $ */
+/* $Id: wddx.c,v 1.46 2000/06/21 18:22:22 thies Exp $ */
#include "php.h"
#include "php_wddx.h"
#if HAVE_WDDX
+#include "ext/standard/php_var.h" /* for php_create_empty_class */
+
#include "php_wddx_api.h"
#define PHP_XML_INTERNAL
#include "ext/xml/php_xml.h"
@@ -739,8 +741,13 @@
if (zend_hash_find(EG(class_table), ent1->data->value.str.val,
ent1->data->value.str.len+1, (void **) &ce)==FAILURE) {
+
+ ce =
php_create_empty_class(ent1->data->value.str.val,ent1->data->value.str.len);
+
+ /*
php_error(E_NOTICE, "Deserializing non-existant class: %s! No methods will be
available!", ent1->data->value.str.val);
ce = &zend_standard_class_def;
+ */
}
/* Initialize target object */