|  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
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.
Block user comment
Status: Assign to:
Bug Type:
From: jules dot bernable at gmail dot com
New email:
PHP Version: OS:


 [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


AllCommentsChangesGit/SVN commitsRelated reports
 [2022-08-17 05:25 UTC] prestigecitytownshipsarjapur at gmail dot com
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Sat Oct 01 21:05:52 2022 UTC