zend_class_entry *domxsltstylesheet_class_entry;
#endif
+static int xslt_has_xsl_keys (xmlDocPtr doc);
static int node_attributes(zval **attributes, xmlNode *nodep TSRMLS_DC);
static int node_children(zval **children, xmlNode *nodep TSRMLS_DC);
/* }}} */
#endif
+static int xslt_has_xsl_keys (xmlDocPtr doc) {
+
+ xmlNode *nodep;
+ nodep = xmlDocGetRootElement(doc)->children;
+ while (nodep) {
+ if (nodep->type == XML_ELEMENT_NODE && xmlStrEqual(nodep->name, "key") && xmlStrEqual(nodep->ns->href, XSLT_NAMESPACE)) {
+ return 1;
+ break;
+ }
+ nodep = nodep->next;
+ }
+ return 0;
+}
+
+
/* {{{ int node_attributes(zval **attributes, int node)
Returns list of children nodes */
static int node_attributes(zval **attributes, xmlNode *nodep TSRMLS_DC)
xmlDocPtr xmldocp;
xmlDocPtr docp;
char **params = NULL;
- int ret, clone = 0;
+ int ret, clone = -1;
char *filename;
int filename_len = 0;
FILE *f;
}
DOMXML_GET_OBJ(xmldocp, idxml, le_domxmldocp);
-
+ if (clone == -1 && xslt_has_xsl_keys(xsltstp->doc) == 1) {
+ clone = 1;
+ }
+
if (idparams) {
params = php_domxslt_make_params(idparams, xpath_params TSRMLS_CC);
}
--- /dev/null
+--TEST--
+Bug #26384 (domxslt->process causes segfault with xsl:key)
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+$xml = domxml_open_mem(file_get_contents(dirname(__FILE__)."/area_name.xml"));
+$xslt = domxml_xslt_stylesheet_file(dirname(__FILE__).'/area_list.xsl');
+print $xslt->process($xml, Array(), null, null);
+
+--EXPECT--
+Object