ID: 43490
Updated by: [EMAIL PROTECTED]
Reported By: claus at phpmind dot net
-Status: Open
+Status: Bogus
Bug Type: DOM XML related
Operating System: Gentoo 2.6.23 / Apache 2.2.6
PHP Version: 5.2.5
New Comment:
You completely ignored my response from previous bug and you didnt call
the parent's constructor when you overrode it.
class guestbook extends domdocument {
function guestbook($file){
parent::__construct();
$this->preserveWhiteSpace = FALSE;
...
alternatively set the props after loading the document. Either way you
need the underlying document structure (created during construction -
which you arent calling - or after a document is loaded) before setting
those properties.
Still bogus because it works as it should.
Previous Comments:
------------------------------------------------------------------------
[2007-12-03 22:51:51] claus at phpmind dot net
Description:
------------
Follow-up on bug report ID #31934
Original report:
----------------
I made a subclass which extends the domdocument class. When i try to
set
the formatOutput or preserveWhiteSpace property within this subclass,
it
doesnt work.
when i create a domdocument object and set it not through a subclass,
it
works fine. I dont know if this is a bug?!
Initial response, [EMAIL PROTECTED]
----------------
in order to get those properties set in your class constructor, you
need
to call parent::__construct(); as your first line in your constructor.
Update:
----------------
Of course you need to run the constructor of the parent class - but
that doesn't fix the problem. When using saveXML() on the subclass
instance the format is still not formatted regardless of the setting of
the subclass property, even if it was set by calling the parent's
constructor first and then either:
a) setting the property directly, be it from the subclass instance or
the $this internal key
b) using the __set() method called as parent::__set('formatOutput',
true);
Both do not work. Please reconsider this bug report as it still appears
to be a bug that's soon to be three years old. You were too quick to
mark this as bogus - apparently you did not even try the reproduction
code from Michael Mezger.
Reproduce code:
---------------
class guestbook extends domdocument {
function guestbook($file){
$this->preserveWhiteSpace = FALSE;
$this->formatOutput = TRUE; //format the guestbook.xml
$this->load($file); //load XML File
$this->save($file);
}
}
$guestbook = new guestbook("test.xml");
var_dump($guestbook->preserveWhiteSpace); //echo: (boolean) true
var_dump($guestbook->formatOutput); //echo: (boolean) false
//This code above works
$guestbook2 = new domdocument();
$guestbook2->load("test.xml");
$guestbook2->preserveWhiteSpace = FALSE;
$guestbook2->formatOutput = TRUE;
var_dump($guestbook2->preserveWhiteSpace); //echo: (boolean) false
var_dump($guestbook2->formatOutput); //echo: (boolean) true
Expected result:
----------------
Would expect output to be formatted at least with one of the applied
methods of setting the parent class (DOMDocument) properties, see
description.
Actual result:
--------------
Output is not formatted (property formatOutput), whitespace is not
preserved (property preserveWhitespace). Apparently the properties of
the DOMDocument class are not respected when using a subclass which
extends the DOMDocument class.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=43490&edit=1