Skip to content
This repository was archived by the owner on Mar 29, 2024. It is now read-only.

Commit 8b16125

Browse files
committed
Disable ObjectTemplate::MarkAsUndetectable() method
1 parent a96667d commit 8b16125

File tree

3 files changed

+35
-13
lines changed

3 files changed

+35
-13
lines changed

src/php_v8_object_template.cc

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,8 @@ static PHP_METHOD(V8ObjectTemplate, SetCallAsFunctionHandler) {
371371

372372
local_template->SetCallAsFunctionHandler(callback, data);
373373
}
374-
374+
// NOTE: Method is not supported anymore due to a limited use and a way it implemented (causes segfault under certain conditions)
375+
/*
375376
static PHP_METHOD(V8ObjectTemplate, MarkAsUndetectable) {
376377
if (zend_parse_parameters_none() == FAILURE) {
377378
return;
@@ -384,6 +385,7 @@ static PHP_METHOD(V8ObjectTemplate, MarkAsUndetectable) {
384385
385386
local_template->MarkAsUndetectable();
386387
}
388+
*/
387389

388390
// not used currently
389391
static PHP_METHOD(V8ObjectTemplate, SetAccessCheckCallback) {
@@ -479,15 +481,20 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_php_v8_object_template_SetCallAsFunctionHandler,
479481
ZEND_ARG_INFO(0, callback)
480482
ZEND_END_ARG_INFO()
481483

484+
// not used
482485
// void method
486+
/*
483487
ZEND_BEGIN_ARG_INFO_EX(arginfo_php_v8_object_template_MarkAsUndetectable, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
484488
ZEND_END_ARG_INFO()
489+
*/
485490

486491
// not used
487492
// void method
493+
/*
488494
ZEND_BEGIN_ARG_INFO_EX(arginfo_php_v8_object_template_SetAccessCheckCallback, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
489495
ZEND_ARG_CALLABLE_INFO(0, callback, 1)
490496
ZEND_END_ARG_INFO()
497+
*/
491498

492499
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_v8_object_template_AdjustExternalAllocatedMemory, ZEND_RETURN_VALUE, 1, IS_LONG, NULL, 0)
493500
ZEND_ARG_TYPE_INFO(0, change_in_bytes, IS_LONG, 0)
@@ -513,7 +520,7 @@ static const zend_function_entry php_v8_object_template_methods[] = {
513520
PHP_ME(V8ObjectTemplate, SetHandlerForNamedProperty, arginfo_php_v8_object_template_SetHandlerForNamedProperty, ZEND_ACC_PUBLIC)
514521
PHP_ME(V8ObjectTemplate, SetHandlerForIndexedProperty, arginfo_php_v8_object_template_SetHandlerForIndexedProperty, ZEND_ACC_PUBLIC)
515522
PHP_ME(V8ObjectTemplate, SetCallAsFunctionHandler, arginfo_php_v8_object_template_SetCallAsFunctionHandler, ZEND_ACC_PUBLIC)
516-
PHP_ME(V8ObjectTemplate, MarkAsUndetectable, arginfo_php_v8_object_template_MarkAsUndetectable, ZEND_ACC_PUBLIC)
523+
// PHP_ME(V8ObjectTemplate, MarkAsUndetectable, arginfo_php_v8_object_template_MarkAsUndetectable, ZEND_ACC_PUBLIC)
517524
// PHP_ME(V8ObjectTemplate, SetAccessCheckCallback, arginfo_php_v8_object_template_SetAccessCheckCallback, ZEND_ACC_PUBLIC)
518525

519526
PHP_ME(V8ObjectTemplate, AdjustExternalAllocatedMemory, arginfo_v8_object_template_AdjustExternalAllocatedMemory, ZEND_ACC_PUBLIC)

stubs/src/ObjectTemplate.php

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -142,17 +142,31 @@ public function SetCallAsFunctionHandler(callable $callback)
142142
{
143143
}
144144

145-
/**
146-
* Mark object instances of the template as undetectable.
147-
*
148-
* In many ways, undetectable objects behave as though they are not
149-
* there. They behave like 'undefined' in conditionals and when
150-
* printed. However, properties can be accessed and called as on
151-
* normal objects.
152-
*/
153-
public function MarkAsUndetectable()
154-
{
155-
}
145+
// Method is not supported anymore due to a limited use and a way it implemented (causes segfault under certain conditions)
146+
// see v8/src/api-natives.cc:677
147+
// // Mark as undetectable if needed.
148+
// if (obj->undetectable()) {
149+
// // We only allow callable undetectable receivers here, since this whole
150+
// // undetectable business is only to support document.all, which is both
151+
// // undetectable and callable. If we ever see the need to have an object
152+
// // that is undetectable but not callable, we need to update the types.h
153+
// // to allow encoding this.
154+
// CHECK(!obj->instance_call_handler()->IsUndefined(isolate));
155+
// map->set_is_undetectable();
156+
// }
157+
158+
159+
///**
160+
// * Mark object instances of the template as undetectable.
161+
// *
162+
// * In many ways, undetectable objects behave as though they are not
163+
// * there. They behave like 'undefined' in conditionals and when
164+
// * printed. However, properties can be accessed and called as on
165+
// * normal objects.
166+
// */
167+
//public function MarkAsUndetectable()
168+
//{
169+
//}
156170

157171
// Disabled due to https://groups.google.com/forum/#!topic/v8-dev/c7LhW2bNabY and it should be not necessary to use
158172
// it in other then browser setup in most cases, though It would be nice to have it for API consistency reason.

tests/V8ObjectTemplate_MarkAsUndetectable.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
--TEST--
22
V8\ObjectTemplate::MarkAsUndetectable
33
--SKIPIF--
4+
<?php print "skip Method is not supported anymore due to a limited use and a way it implemented (causes segfault under certain conditions)"; ?>
45
<?php if (!extension_loaded("v8")) { print "skip"; } ?>
56
--FILE--
67
<?php

0 commit comments

Comments
 (0)