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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Mon Apr 29 12:01:32 2024 UTC