rrichards Fri May 4 19:32:19 2007 UTC
Modified files:
/php-src/ext/dom element.c node.c
/php-src/ext/dom/tests bug41257.phpt
Log:
MFB: fix bug #41257 (lookupNamespaceURI does not work as expected)
fix related issue in isDefaultNamespace
add test
reconcile namespaces when setting attribute in a new namespace
http://cvs.php.net/viewvc.cgi/php-src/ext/dom/element.c?r1=1.52&r2=1.53&diff_format=u
Index: php-src/ext/dom/element.c
diff -u php-src/ext/dom/element.c:1.52 php-src/ext/dom/element.c:1.53
--- php-src/ext/dom/element.c:1.52 Mon Jan 1 09:29:23 2007
+++ php-src/ext/dom/element.c Fri May 4 19:32:19 2007
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: element.c,v 1.52 2007/01/01 09:29:23 sebastian Exp $ */
+/* $Id: element.c,v 1.53 2007/05/04 19:32:19 rrichards Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -709,6 +709,7 @@
} else {
nsptr = dom_get_ns(elemp, uri,
&errorcode, prefix);
}
+ xmlReconciliateNs(elemp->doc, elemp);
}
} else {
if (is_xmlns == 1) {
http://cvs.php.net/viewvc.cgi/php-src/ext/dom/node.c?r1=1.55&r2=1.56&diff_format=u
Index: php-src/ext/dom/node.c
diff -u php-src/ext/dom/node.c:1.55 php-src/ext/dom/node.c:1.56
--- php-src/ext/dom/node.c:1.55 Sun Mar 18 21:29:20 2007
+++ php-src/ext/dom/node.c Fri May 4 19:32:19 2007
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: node.c,v 1.55 2007/03/18 21:29:20 rrichards Exp $ */
+/* $Id: node.c,v 1.56 2007/05/04 19:32:19 rrichards Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -1587,8 +1587,11 @@
}
DOM_GET_OBJ(nodep, id, xmlNodePtr, intern);
+ if (nodep->type == XML_DOCUMENT_NODE || nodep->type ==
XML_HTML_DOCUMENT_NODE) {
+ nodep = xmlDocGetRootElement((xmlDocPtr) nodep);
+ }
- if (uri_len > 0) {
+ if (nodep && uri_len > 0) {
nsptr = xmlSearchNs(nodep->doc, nodep, NULL);
if (nsptr && xmlStrEqual(nsptr->href, uri)) {
RETURN_TRUE;
@@ -1618,6 +1621,12 @@
}
DOM_GET_OBJ(nodep, id, xmlNodePtr, intern);
+ if (nodep->type == XML_DOCUMENT_NODE || nodep->type ==
XML_HTML_DOCUMENT_NODE) {
+ nodep = xmlDocGetRootElement((xmlDocPtr) nodep);
+ if (nodep == NULL) {
+ RETURN_NULL();
+ }
+ }
nsptr = xmlSearchNs(nodep->doc, nodep, prefix);
if (nsptr && nsptr->href != NULL) {
http://cvs.php.net/viewvc.cgi/php-src/ext/dom/tests/bug41257.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/dom/tests/bug41257.phpt
diff -u /dev/null php-src/ext/dom/tests/bug41257.phpt:1.2
--- /dev/null Fri May 4 19:32:19 2007
+++ php-src/ext/dom/tests/bug41257.phpt Fri May 4 19:32:19 2007
@@ -0,0 +1,31 @@
+--TEST--
+Bug # 41257: (lookupNamespaceURI does not work as expected)
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+
+$doc = new DOMDocument();
+$doc->load(dirname(__FILE__)."/nsdoc.xml");
+
+$root = $doc->documentElement;
+
+$duri = $doc->lookupNamespaceURI("ns2")."\n";
+$euri = $root->lookupNamespaceURI("ns2")."\n";
+
+var_dump($duri == $euri);
+
+$dpref = $doc->lookupPrefix("http://ns2")."\n";
+$epref = $root->lookupPrefix("http://ns2")."\n";
+
+var_dump($dpref == $epref);
+
+$disdef = $doc->isDefaultNamespace("http://ns")."\n";
+$eisdef = $root->isDefaultNamespace("http://ns")."\n";
+
+var_dump($dpref === $epref);
+?>
+--EXPECT--
+bool(true)
+bool(true)
+bool(true)
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php