mirror of
https://github.com/php/php-src.git
synced 2024-09-22 02:17:32 +00:00
Fix remaining XPath issue
This commit is contained in:
parent
39d12294fd
commit
59f6d189c8
@ -842,7 +842,7 @@ PHP_MINIT_FUNCTION(dom)
|
||||
|
||||
#if defined(LIBXML_XPATH_ENABLED)
|
||||
memcpy(&dom_xpath_object_handlers, &dom_object_handlers, sizeof(zend_object_handlers));
|
||||
dom_xpath_object_handlers.offset = XtOffsetOf(dom_xpath_object, std);
|
||||
dom_xpath_object_handlers.offset = XtOffsetOf(dom_xpath_object, dom) + XtOffsetOf(dom_object, std);
|
||||
dom_xpath_object_handlers.free_obj = dom_xpath_objects_free_storage;
|
||||
|
||||
INIT_CLASS_ENTRY(ce, "DOMXPath", php_dom_xpath_class_functions);
|
||||
@ -1011,12 +1011,11 @@ void dom_xpath_objects_free_storage(zend_object *object TSRMLS_DC)
|
||||
{
|
||||
dom_xpath_object *intern = php_xpath_obj_from_obj(object);
|
||||
|
||||
zend_object_std_dtor(&intern->std TSRMLS_CC);
|
||||
zend_object_std_dtor(&intern->dom.std TSRMLS_CC);
|
||||
|
||||
if (intern->ptr != NULL) {
|
||||
xmlXPathFreeContext((xmlXPathContextPtr) intern->ptr);
|
||||
php_libxml_decrement_doc_ref((php_libxml_node_object *) intern TSRMLS_CC);
|
||||
intern->ptr = NULL;
|
||||
if (intern->dom.ptr != NULL) {
|
||||
xmlXPathFreeContext((xmlXPathContextPtr) intern->dom.ptr);
|
||||
php_libxml_decrement_doc_ref((php_libxml_node_object *) &intern->dom TSRMLS_CC);
|
||||
}
|
||||
|
||||
if (intern->registered_phpfunctions) {
|
||||
@ -1143,13 +1142,13 @@ zend_object *dom_xpath_objects_new(zend_class_entry *class_type TSRMLS_DC)
|
||||
ALLOC_HASHTABLE(intern->registered_phpfunctions);
|
||||
zend_hash_init(intern->registered_phpfunctions, 0, NULL, ZVAL_PTR_DTOR, 0);
|
||||
|
||||
intern->prop_handler = &dom_xpath_prop_handlers;
|
||||
intern->std.handlers = &dom_xpath_object_handlers;
|
||||
intern->dom.prop_handler = &dom_xpath_prop_handlers;
|
||||
intern->dom.std.handlers = &dom_xpath_object_handlers;
|
||||
|
||||
zend_object_std_init(&intern->std, class_type TSRMLS_CC);
|
||||
object_properties_init(&intern->std, class_type);
|
||||
zend_object_std_init(&intern->dom.std, class_type TSRMLS_CC);
|
||||
object_properties_init(&intern->dom.std, class_type);
|
||||
|
||||
return &intern->std;
|
||||
return &intern->dom.std;
|
||||
}
|
||||
/* }}} */
|
||||
#endif
|
||||
|
@ -68,17 +68,15 @@ extern zend_module_entry dom_module_entry;
|
||||
#define DOM_NODESET XML_XINCLUDE_START
|
||||
|
||||
typedef struct _dom_xpath_object {
|
||||
void *ptr;
|
||||
php_libxml_ref_obj *document;
|
||||
HashTable *prop_handler;
|
||||
int registerPhpFunctions;
|
||||
HashTable *registered_phpfunctions;
|
||||
HashTable *node_list;
|
||||
zend_object std;
|
||||
dom_object dom;
|
||||
} dom_xpath_object;
|
||||
|
||||
static inline dom_xpath_object *php_xpath_obj_from_obj(zend_object *obj) {
|
||||
return (dom_xpath_object*)((char*)(obj) - XtOffsetOf(dom_xpath_object, std));
|
||||
return (dom_xpath_object*)((char*)(obj)
|
||||
- XtOffsetOf(dom_xpath_object, dom) - XtOffsetOf(dom_object, std));
|
||||
}
|
||||
|
||||
#define Z_XPATHOBJ_P(zv) php_xpath_obj_from_obj(Z_OBJ_P((zv)))
|
||||
|
@ -159,7 +159,7 @@ static void dom_xpath_ext_function_php(xmlXPathParserContextPtr ctxt, int nargs,
|
||||
node->parent = nsparent;
|
||||
node->ns = curns;
|
||||
}
|
||||
php_dom_create_object(node, &child, (dom_object *)intern TSRMLS_CC);
|
||||
php_dom_create_object(node, &child, &intern->dom TSRMLS_CC);
|
||||
add_next_index_zval(&fci.params[i], &child);
|
||||
}
|
||||
}
|
||||
@ -277,9 +277,9 @@ PHP_METHOD(domxpath, __construct)
|
||||
|
||||
intern = Z_XPATHOBJ_P(id);
|
||||
if (intern != NULL) {
|
||||
oldctx = (xmlXPathContextPtr)intern->ptr;
|
||||
oldctx = (xmlXPathContextPtr)intern->dom.ptr;
|
||||
if (oldctx != NULL) {
|
||||
php_libxml_decrement_doc_ref((php_libxml_node_object *)intern TSRMLS_CC);
|
||||
php_libxml_decrement_doc_ref((php_libxml_node_object *) &intern->dom TSRMLS_CC);
|
||||
xmlXPathFreeContext(oldctx);
|
||||
}
|
||||
|
||||
@ -290,10 +290,10 @@ PHP_METHOD(domxpath, __construct)
|
||||
(const xmlChar *) "http://php.net/xpath",
|
||||
dom_xpath_ext_function_object_php);
|
||||
|
||||
intern->ptr = ctx;
|
||||
intern->dom.ptr = ctx;
|
||||
ctx->userData = (void *)intern;
|
||||
intern->document = docobj->document;
|
||||
php_libxml_increment_doc_ref((php_libxml_node_object *)intern, docp TSRMLS_CC);
|
||||
intern->dom.document = docobj->document;
|
||||
php_libxml_increment_doc_ref((php_libxml_node_object *) &intern->dom, docp TSRMLS_CC);
|
||||
}
|
||||
}
|
||||
/* }}} end DOMXPath::__construct */
|
||||
@ -328,7 +328,7 @@ PHP_FUNCTION(dom_xpath_register_ns)
|
||||
|
||||
intern = Z_XPATHOBJ_P(id);
|
||||
|
||||
ctxp = (xmlXPathContextPtr) intern->ptr;
|
||||
ctxp = (xmlXPathContextPtr) intern->dom.ptr;
|
||||
if (ctxp == NULL) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid XPath Context");
|
||||
RETURN_FALSE;
|
||||
@ -370,7 +370,7 @@ static void php_xpath_eval(INTERNAL_FUNCTION_PARAMETERS, int type) /* {{{ */
|
||||
|
||||
intern = Z_XPATHOBJ_P(id);
|
||||
|
||||
ctxp = (xmlXPathContextPtr) intern->ptr;
|
||||
ctxp = (xmlXPathContextPtr) intern->dom.ptr;
|
||||
if (ctxp == NULL) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid XPath Context");
|
||||
RETURN_FALSE;
|
||||
@ -463,7 +463,7 @@ static void php_xpath_eval(INTERNAL_FUNCTION_PARAMETERS, int type) /* {{{ */
|
||||
node->parent = nsparent;
|
||||
node->ns = curns;
|
||||
}
|
||||
php_dom_create_object(node, &child, (dom_object *)intern TSRMLS_CC);
|
||||
php_dom_create_object(node, &child, &intern->dom TSRMLS_CC);
|
||||
add_next_index_zval(&retval, &child);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user