Bug #73981 [NEW]: __construct not being called on extensions of DOM base classes
| From: | work at timothytown dot com | Date: | Mon, 23 Jan 2017 18:13:11 +0000 |
| Subject: | Bug #73981 [NEW]: __construct not being called on extensions of DOM base classes | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-206902@lists.php.net to get a copy of this message | ||
From: work at timothytown dot com
Operating system: windows
PHP version: 7.1.1
Package: *General Issues
Bug Type: Bug
Bug description:__construct not being called on extensions of DOM base classes
Description:
------------
When a class is registered to a DOMDocument via the registerNodeClass
method, the assigned class is used to instance the return object from
the DOMDOcument. However, the construct method of that class is not
called.
Test script:
---------------
class SillyTestClass extends DOMElement{
public $foo=null;
public function __construct($name,$value=null,$namespace=null){
echo "calling child construct....";
$this->foo="bar";
parent::__construct($name,$value,$namespace);
}
public function sayHello(){
echo "Why, hello there!";
}
}
$doc=new DOMDocument();
$doc->registerNodeClass('DOMElement','SillyTestClass');
$doc->loadHTML("<div><h1>Sample</h1></div>");
//THIS WORKS! CUSTOM CLASS BEING USED
$doc->documentElement->firstChild->sayHello();
//THIS IS STILL NULL:( Never set by construct, no message saying
construct was called either
echo $doc->documentElement->firstChild->foo;
Expected result:
----------------
output "calling child construct..." //printed from child _construct
output "Why, hello there!" //printed from child method sayHello()
output "bar" //the value of child property after being assigned in
constructor
Actual result:
--------------
//only the sayHello() method fires; construct doesn't happen
Why, hello there;
--
Edit bug report at https://bugs.php.net/bug.php?id=73981&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=73981&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=73981&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=73981&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=73981&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=73981&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=73981&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=73981&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=73981&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=73981&r=support
Expected behavior: https://bugs.php.net/fix.php?id=73981&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=73981&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=73981&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=73981&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=73981&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=73981&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=73981&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=73981&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=73981&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=73981&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=73981&r=mysqlcfg