Skip to content

Commit 66b90c7

Browse files
committed
Final ze1_compat restoration - it was mostly done by hand, so if anybody
spots any (new) problems, let me know. Test wise, the same tests that failed before are failing now.
1 parent b1683ea commit 66b90c7

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed

ext/dom/php_dom.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ zend_class_entry *dom_xpath_class_entry;
6969
zend_class_entry *dom_namespace_node_class_entry;
7070

7171
zend_object_handlers dom_object_handlers;
72+
zend_object_handlers dom_ze1_object_handlers;
7273

7374
static HashTable classes;
7475

@@ -490,12 +491,25 @@ zend_object_value dom_objects_store_clone_obj(zval *zobject TSRMLS_DC)
490491
return retval;
491492
}
492493

494+
495+
zend_object_value dom_objects_ze1_clone_obj(zval *zobject TSRMLS_DC)
496+
{
497+
php_error(E_ERROR, "Cannot clone object of class %s due to 'zend.ze1_compatibility_mode'", Z_OBJCE_P(zobject)->name);
498+
/* Return zobject->value.obj just to satisfy compiler */
499+
return zobject->value.obj;
500+
}
501+
493502
static zend_function_entry dom_functions[] = {
494503
PHP_FE(dom_import_simplexml, NULL)
495504
{NULL, NULL, NULL}
496505
};
497506

498507
static zend_object_handlers* dom_get_obj_handlers(TSRMLS_D) {
508+
if (EG(ze1_compatibility_mode)) {
509+
return &dom_ze1_object_handlers;
510+
} else {
511+
return &dom_object_handlers;
512+
}
499513
return &dom_object_handlers;
500514
}
501515

@@ -535,6 +549,13 @@ PHP_MINIT_FUNCTION(dom)
535549
dom_object_handlers.clone_obj = dom_objects_store_clone_obj;
536550
dom_object_handlers.has_property = dom_property_exists;
537551

552+
memcpy(&dom_ze1_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
553+
dom_ze1_object_handlers.read_property = dom_read_property;
554+
dom_ze1_object_handlers.write_property = dom_write_property;
555+
dom_object_handlers.get_property_ptr_ptr = dom_get_property_ptr_ptr;
556+
dom_ze1_object_handlers.clone_obj = dom_objects_ze1_clone_obj;
557+
dom_ze1_object_handlers.has_property = dom_property_exists;
558+
538559
zend_hash_init(&classes, 0, NULL, NULL, 1);
539560

540561
INIT_CLASS_ENTRY(ce, "DOMException", php_dom_domexception_class_functions);

ext/simplexml/simplexml.c

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1689,6 +1689,38 @@ static zend_object_handlers sxe_object_handlers = {
16891689
sxe_count_elements
16901690
};
16911691

1692+
static zend_object_handlers sxe_ze1_object_handlers = {
1693+
ZEND_OBJECTS_STORE_HANDLERS,
1694+
sxe_property_read,
1695+
sxe_property_write,
1696+
sxe_dimension_read,
1697+
sxe_dimension_write,
1698+
sxe_property_get_adr,
1699+
sxe_get_value, /* get */
1700+
NULL,
1701+
sxe_property_exists,
1702+
sxe_property_delete,
1703+
sxe_dimension_exists,
1704+
sxe_dimension_delete,
1705+
sxe_properties_get,
1706+
NULL, /* zend_get_std_object_handlers()->get_method,*/
1707+
NULL, /* zend_get_std_object_handlers()->call_method,*/
1708+
NULL, /* zend_get_std_object_handlers()->get_constructor, */
1709+
NULL, /* zend_get_std_object_handlers()->get_class_entry,*/
1710+
NULL, /* zend_get_std_object_handlers()->get_class_name,*/
1711+
sxe_objects_compare,
1712+
sxe_object_cast,
1713+
sxe_count_elements
1714+
};
1715+
1716+
static zend_object_value sxe_object_ze1_clone(zval *zobject TSRMLS_DC)
1717+
{
1718+
php_error(E_ERROR, "Cannot clone object of class %s due to 'zend.ze1_compatibility_mode'", Z_OBJCE_P(zobject)->name);
1719+
/* Return zobject->value.obj just to satisfy compiler */
1720+
/* FIXME: Should not be a fatal */
1721+
return zobject->value.obj;
1722+
}
1723+
16921724
/* {{{ sxe_object_clone()
16931725
*/
16941726
static void
@@ -2239,6 +2271,12 @@ PHP_MINIT_FUNCTION(simplexml)
22392271
sxe_object_handlers.get_class_entry = zend_get_std_object_handlers()->get_class_entry;
22402272
sxe_object_handlers.get_class_name = zend_get_std_object_handlers()->get_class_name;
22412273

2274+
sxe_ze1_object_handlers.get_method = zend_get_std_object_handlers()->get_method;
2275+
sxe_ze1_object_handlers.get_constructor = zend_get_std_object_handlers()->get_constructor;
2276+
sxe_ze1_object_handlers.get_class_entry = zend_get_std_object_handlers()->get_class_entry;
2277+
sxe_ze1_object_handlers.get_class_name = zend_get_std_object_handlers()->get_class_name;
2278+
sxe_ze1_object_handlers.clone_obj = sxe_object_ze1_clone;
2279+
22422280
#ifdef HAVE_SPL
22432281
if (zend_get_module_started("spl") == SUCCESS) {
22442282
PHP_MINIT(spl_sxe)(INIT_FUNC_ARGS_PASSTHRU);

0 commit comments

Comments
 (0)