#43490 [NEW]: DOMDocument properties not respected when set in subclass extending DOMDocument

From: Date: Mon, 03 Dec 2007 22:51:51 +0000
Subject: #43490 [NEW]: DOMDocument properties not respected when set in subclass extending DOMDocument
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-120342@lists.php.net to get a copy of this message
From: claus at phpmind dot net Operating system: Gentoo 2.6.23 / Apache 2.2.6 PHP version: 5.2.5 PHP Bug Type: DOM XML related Bug description: DOMDocument properties not respected when set in subclass extending DOMDocument 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, rrichards@php.net ---------------- 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 bug report at http://bugs.php.net/?id=43490&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=43490&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=43490&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=43490&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=43490&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=43490&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=43490&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=43490&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=43490&r=needscript Try newer version: http://bugs.php.net/fix.php?id=43490&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=43490&r=support Expected behavior: http://bugs.php.net/fix.php?id=43490&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=43490&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=43490&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=43490&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=43490&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=43490&r=dst IIS Stability: http://bugs.php.net/fix.php?id=43490&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=43490&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=43490&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=43490&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=43490&r=mysqlcfg

« previous php.bugs (#120342) next »