|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43107 access level of DOM* properties are not applied
Submitted: 2007-10-26 07:02 UTC Modified: 2007-11-14 16:56 UTC
Avg. Score:2.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: php at benjaminschulz dot com Assigned: rrichards (profile)
Status: Wont fix Package: DOM XML related
PHP Version: 5.3CVS-2007-10-26 (CVS) OS:
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2007-10-26 07:02 UTC] php at benjaminschulz dot com
I need to restrict the direct setting of DOM* properties to ensure that no non-utf8 encoding is getting into the Document because libxml2 (ext/dom?) still can't handle that. Implementing this i discovered that classes derived from DOM* cannot restrict the access level of properties.
I think there should at least be an error raised telling that it is not allowed to change the access level of properties, but because of libxml's great  segfaulting abilities i would prefer to able to restrict the access (without a magic setter). Another solution for the encoding problem might be to just check _all_ incoming strings into the DomDocument for unicode if the documents encoding is UTF-8.

Reproduce code:
class Test extends DomDocument {
    protected $textContent;   

$test = new Test;

Expected result:
Fatal Error: Cannot access protected property Text::$textContent

Actual result:
string(3) "bar" 


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2007-11-12 10:12 UTC]
Assigned to the maintainer.
 [2007-11-13 06:42 UTC]
Rob, can you look into that? I have no idea about that part of code, not 
even if it's possible :)
 [2007-11-14 16:00 UTC]
First off you can't make the visibility of properties stricter.
DOM properties can't be overridden because there would then be no way to access the underlying functionality. I don't see a way to provide any warnings for this, due to how the way properties are implemented in DOM, so just comes down to the fact that you cant override DOM properties and to validate your input.
 [2007-11-14 16:18 UTC] php at benjaminschulz dot com
"DOM properties can't be overridden because there would then be no way 
access the underlying functionality."

That's exactly the point - i don't want some functionality to be 
accessed. If i would want to use the DomDocument as it is i won't need 
to extend it, right?
 [2007-11-14 16:56 UTC]
What I'm saying is that the properties being final is the limiting factor when extending the DOM classes and was done purposely.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Jun 20 22:01:29 2024 UTC