|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #81682 DocumentType nodes cannot be cloned nor imported
Submitted: 2021-12-01 08:01 UTC Modified: -
From: jules dot bernable at gmail dot com Assigned:
Status: Open Package: DOM XML related
PHP Version: 8.1.0 OS: irrelevant
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
Solve the problem:
38 - 5 = ?
Subscribe to this entry?

 [2021-12-01 08:01 UTC] jules dot bernable at gmail dot com
When trying to clone or import a doctype node, the operation always fail.
AFAICT there's nothing in the DOM standard saying this should be the case (see

Test script:
$original = new DOMDocument();
$original->loadHTML('<!DOCTYPE html>');
$docytpe = $original->doctype->cloneNode();
var_dump($doctype); // false

$other = new DOMDocument();
$doctype = $other->importNode($original->doctype);
var_dump($doctype); // false

Expected result:
The result should be a new DocumentType node with the same name, publicId and systemId and, in the case of importNode, associated with the new document.


Add a Patch

Pull Requests

Add a Pull Request

PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Mon May 23 03:05:45 2022 UTC