php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #70026 Instances of DOMDocument lose derived class information when refcount low
Submitted: 2015-07-08 15:18 UTC Modified: 2019-09-22 22:35 UTC
From: dexen dot devries at gmail dot com Assigned: beberlei (profile)
Status: Wont fix Package: DOM XML related
PHP Version: 5.6.10 OS: Linux
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:
MUST BE VALID
Solve the problem:
20 - 17 = ?
Subscribe to this entry?

 
 [2015-07-08 15:18 UTC] dexen dot devries at gmail dot com
Description:
------------
DOMXPath instances mis-handle instances of classes derived from DOMDocument in some cases, as accessible via $document property. Instances of classes derived from DOMDocument can suffer loss of information, both on derived class type and properties of the derived class.

Both derived class name and properties of instance of the derived class are lost.

Problems seems to be related to refcount going down to zero; can be reliably triggered both by returning instance of DOMDocument derived class from function, and by manually unset()ting all variables refering to the instance of class derived from DOMDocument.

Test script:
---------------
http://pastebin.ca/3051231

Expected result:
----------------
Instance of DOMXPath should hold the original DOMDocument instances in $document property.

Actual result:
--------------
Instance of DOMXPath holds some sort of copy of DOMDocument instance in $document, if refcount goes to zero, resulting in loss of both derived class information, and properties of the derived class.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-07-10 16:04 UTC] cmb@php.net
That seems to be related to bug #61797.
 [2019-09-22 22:35 UTC] beberlei@php.net
-Status: Open +Status: Wont fix -Assigned To: +Assigned To: beberlei
 [2019-09-22 22:35 UTC] beberlei@php.net
This is not a bug. You should see the document property as using "magic" __get and creating new DOMDocument objects as it needs them based on the underlying libxml DOM structure that is managed. ext/dom does not guarantee reference equality of nodes.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 12:01:28 2024 UTC