mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Mark DOM classes as not serializable
This commit is contained in:
parent
1c675b9d0d
commit
ca94d55a19
3 changed files with 49 additions and 1 deletions
|
@ -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 */
|
||||
|
|
|
@ -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;
|
||||
|
|
42
ext/dom/tests/not_serializable.phpt
Normal file
42
ext/dom/tests/not_serializable.phpt
Normal file
|
@ -0,0 +1,42 @@
|
|||
--TEST--
|
||||
DOM classes are not serializable
|
||||
--EXTENSIONS--
|
||||
dom
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
$doc = new DOMDocument();
|
||||
$doc->loadXML('<root><node/></root>');
|
||||
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
|
Loading…
Add table
Add a link
Reference in a new issue