mirror of
https://github.com/phpv8/v8js.git
synced 2024-12-22 03:01:51 +00:00
Test unserialization with properties
This commit is contained in:
parent
c0d1e2fa6d
commit
73d022cca1
@ -20,6 +20,18 @@ catch(\V8JsException $e) {
|
||||
|
||||
$stored = 'O:8:"V8Object":0:{}';
|
||||
|
||||
try {
|
||||
$obj2 = unserialize($stored);
|
||||
}
|
||||
catch(\V8JsException $e) {
|
||||
var_dump(get_class($e));
|
||||
var_dump($e->getMessage());
|
||||
}
|
||||
|
||||
var_dump(isset($obj2));
|
||||
|
||||
$stored = 'O:8:"V8Object":1:{s:3:"foo";i:23;}';
|
||||
|
||||
try {
|
||||
$obj = unserialize($stored);
|
||||
}
|
||||
@ -28,8 +40,7 @@ catch(\V8JsException $e) {
|
||||
var_dump($e->getMessage());
|
||||
}
|
||||
|
||||
$v8->foo = $obj;
|
||||
|
||||
var_dump(isset($obj3));
|
||||
|
||||
?>
|
||||
===EOF===
|
||||
@ -42,4 +53,8 @@ string(13) "V8JsException"
|
||||
string(54) "You cannot serialize or unserialize V8Object instances"
|
||||
string(13) "V8JsException"
|
||||
string(54) "You cannot serialize or unserialize V8Object instances"
|
||||
bool(false)
|
||||
string(13) "V8JsException"
|
||||
string(54) "You cannot serialize or unserialize V8Object instances"
|
||||
bool(false)
|
||||
===EOF===
|
||||
|
@ -25,6 +25,16 @@ catch(\V8JsException $e) {
|
||||
var_dump($e->getMessage());
|
||||
}
|
||||
|
||||
$stored = 'O:4:"V8Js":1:{s:3:"foo";i:23;}';
|
||||
|
||||
try {
|
||||
$b = unserialize($stored);
|
||||
}
|
||||
catch(\V8JsException $e) {
|
||||
var_dump(get_class($e));
|
||||
var_dump($e->getMessage());
|
||||
}
|
||||
|
||||
?>
|
||||
===EOF===
|
||||
--EXPECT--
|
||||
@ -32,4 +42,6 @@ string(13) "V8JsException"
|
||||
string(50) "You cannot serialize or unserialize V8Js instances"
|
||||
string(13) "V8JsException"
|
||||
string(50) "You cannot serialize or unserialize V8Js instances"
|
||||
string(13) "V8JsException"
|
||||
string(50) "You cannot serialize or unserialize V8Js instances"
|
||||
===EOF===
|
||||
|
12
v8js.cc
12
v8js.cc
@ -385,12 +385,16 @@ static HashTable *php_v8js_v8_get_properties(zval *object TSRMLS_DC) /* {{{ */
|
||||
/* the garbage collector is running, don't create more zvals */
|
||||
return NULL;
|
||||
}
|
||||
if (obj->ctx == NULL) {
|
||||
/* Half-constructed object. Shouldn't happen, but be safe. */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ALLOC_HASHTABLE(obj->properties);
|
||||
zend_hash_init(obj->properties, 0, NULL, ZVAL_PTR_DTOR, 0);
|
||||
|
||||
if (!obj->ctx) {
|
||||
/* Half-constructed object, probably due to unserialize call.
|
||||
* Just pass back properties hash so unserialize can write to
|
||||
* it (instead of crashing the engine). */
|
||||
return obj->properties;
|
||||
}
|
||||
} else {
|
||||
zend_hash_clean(obj->properties);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user