php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #38823 DOMComment->appendData does nothing
Submitted: 2006-09-14 10:17 UTC Modified: 2006-09-16 19:14 UTC
From: ladislav dot prosek at matfyz dot cz Assigned:
Status: Not a bug Package: DOM XML related
PHP Version: 5.1.6 OS: Windows XP SP2 Pro
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: ladislav dot prosek at matfyz dot cz
New email:
PHP Version: OS:

 

 [2006-09-14 10:17 UTC] ladislav dot prosek at matfyz dot cz
Description:
------------
Calling appendData() on a DOMComment seems to have zero effect on the comment.

Reproduce code:
---------------
<?
  $doc = new DOMDocument;
  $x = $doc->createComment("a");

  $x->appendData("b");

  echo $x->nodeValue;
?>

Expected result:
----------------
ab

Actual result:
--------------
a

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-09-14 12:42 UTC] tony2001@php.net
Comments do not have data, only text and cdata nodes have it.
 [2006-09-14 12:47 UTC] ladislav dot prosek at matfyz dot cz
Your XML is a bit rusty, isn't it? :))
Of course they do have data. What do you think is the string that you pass to createComment?
 [2006-09-14 12:51 UTC] tony2001@php.net
Tell that to libxml2 authors?

tree.c:
....
int
xmlTextConcat(xmlNodePtr node, const xmlChar *content, int len) {
    if (node == NULL) return(-1);

    if ((node->type != XML_TEXT_NODE) &&
        (node->type != XML_CDATA_SECTION_NODE)) {
#ifdef DEBUG_TREE
    xmlGenericError(xmlGenericErrorContext,
        "xmlTextConcat: node is not text nor CDATA\n");
#endif
        return(-1);
    }
....
 [2006-09-14 12:57 UTC] ladislav dot prosek at matfyz dot cz
If you replace $x->appendData("b") with $x->insertData(1, "b"), it will produce the expected output.

Clearly it is a bug, in PHP or libxml2 (and definitely not bogus). If you're convinced that it's not in PHP, then someone should report it to libxml2. Will you do it or should I?
 [2006-09-14 13:02 UTC] tony2001@php.net
Yes, please report it to libxml2 developers.
 [2006-09-16 19:09 UTC] ladislav dot prosek at matfyz dot cz
Should be fixed in libxml2 now.
 [2006-09-16 19:09 UTC] ladislav dot prosek at matfyz dot cz
http://bugzilla.gnome.org/show_bug.cgi?id=355962
 [2006-09-16 19:14 UTC] bjori@php.net
(Rob also implemented workaround for it in PHP: 
http://news.php.net/php.cvs/40543)
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Apr 16 01:01:26 2025 UTC