diff --git a/ext/dom/php_dom.stub.php b/ext/dom/php_dom.stub.php index c7a08fa9933..42b0f1b356a 100644 --- a/ext/dom/php_dom.stub.php +++ b/ext/dom/php_dom.stub.php @@ -56,6 +56,7 @@ interface DOMChildNode public function replaceWith(...$nodes): void; } +/** @not-serializable */ class DOMNode { /** @readonly */ @@ -155,6 +156,7 @@ class DOMNode public function replaceChild(DOMNode $node, DOMNode $child) {} } +/** @not-serializable */ class DOMNameSpaceNode { /** @readonly */ @@ -654,6 +656,7 @@ class DOMProcessingInstruction extends DOMNode } #ifdef LIBXML_XPATH_ENABLED +/** @not-serializable */ class DOMXPath { /** @readonly */ diff --git a/ext/dom/php_dom_arginfo.h b/ext/dom/php_dom_arginfo.h index 753f44acb4f..ff024d52f64 100644 --- a/ext/dom/php_dom_arginfo.h +++ b/ext/dom/php_dom_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 3db2a5e01c88b189f2d58aa67b598653ebde6a76 */ + * Stub hash: cff5c4b824da940f151617d08bb6b2419a9d26e9 */ ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_dom_import_simplexml, 0, 1, DOMElement, 0) ZEND_ARG_TYPE_INFO(0, node, IS_OBJECT, 0) @@ -989,6 +989,7 @@ static zend_class_entry *register_class_DOMNode(void) INIT_CLASS_ENTRY(ce, "DOMNode", class_DOMNode_methods); class_entry = zend_register_internal_class_ex(&ce, NULL); + class_entry->ce_flags |= ZEND_ACC_NOT_SERIALIZABLE; zval property_nodeName_default_value; ZVAL_UNDEF(&property_nodeName_default_value); @@ -1103,6 +1104,7 @@ static zend_class_entry *register_class_DOMNameSpaceNode(void) INIT_CLASS_ENTRY(ce, "DOMNameSpaceNode", class_DOMNameSpaceNode_methods); class_entry = zend_register_internal_class_ex(&ce, NULL); + class_entry->ce_flags |= ZEND_ACC_NOT_SERIALIZABLE; zval property_nodeName_default_value; ZVAL_UNDEF(&property_nodeName_default_value); @@ -1654,6 +1656,7 @@ static zend_class_entry *register_class_DOMXPath(void) INIT_CLASS_ENTRY(ce, "DOMXPath", class_DOMXPath_methods); class_entry = zend_register_internal_class_ex(&ce, NULL); + class_entry->ce_flags |= ZEND_ACC_NOT_SERIALIZABLE; zend_string *property_document_class_DOMDocument = zend_string_init("DOMDocument", sizeof("DOMDocument")-1, 1); zval property_document_default_value; diff --git a/ext/dom/tests/not_serializable.phpt b/ext/dom/tests/not_serializable.phpt new file mode 100644 index 00000000000..9869a8c87e3 --- /dev/null +++ b/ext/dom/tests/not_serializable.phpt @@ -0,0 +1,42 @@ +--TEST-- +DOM classes are not serializable +--EXTENSIONS-- +dom +--FILE-- +loadXML(''); +try { + serialize($doc); +} catch (Exception $e) { + echo $e->getMessage(), "\n"; +} + +$node = $doc->documentElement; +try { + serialize($node); +} catch (Exception $e) { + echo $e->getMessage(), "\n"; +} + +$xpath = new DOMXPath($doc); +try { + serialize($xpath); +} catch (Exception $e) { + echo $e->getMessage(), "\n"; +} + +$ns = $xpath->query('//namespace::*')->item(0); +try { + serialize($ns); +} catch (Exception $e) { + echo $e->getMessage(), "\n"; +} + +?> +--EXPECT-- +Serialization of 'DOMDocument' is not allowed +Serialization of 'DOMElement' is not allowed +Serialization of 'DOMXPath' is not allowed +Serialization of 'DOMNameSpaceNode' is not allowed