|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2015-09-23 09:39 UTC] sebastian@php.net
Description: ------------ I am seeing weird "DOMDocument::registerNodeClass(): Couldn't fetch TheSeer\fDOM\fDOMDocument" errors when running the fDOMDocument test suite with PHP 7 (current PHP-7.0 branch, problem also present on master). The tests in question work fine with PHP 5.6. This is a regression from PHP 5 to PHP 7. At this time I do not have a minimal, self-contained, reproducing test script but I will try to provide one. Test script: --------------- $ git clone https://github.com/theseer/fDOMDocument.git $ cd fDOMDocument $ wget https://phar.phpunit.de/phpunit.phar $ php phpunit.phar --no-coverage Expected result: ---------------- PHPUnit 4.8.9 by Sebastian Bergmann and contributors. Runtime: PHP 5.6.13 with Xdebug 2.3.3 Configuration: /home/sb/fDOMDocument/phpunit.xml.dist ............................................................... 63 / 120 ( 52%) ......................................................... Time: 153 ms, Memory: 15.25Mb OK (120 tests, 168 assertions) Actual result: -------------- PHPUnit 4.8.9 by Sebastian Bergmann and contributors. Runtime: PHP 7.0.0-dev Configuration: /home/sb/fDOMDocument/phpunit.xml.dist ............................................................... 63 / 120 ( 52%) ................EEE...................................... Time: 420 ms, Memory: 10.00Mb There were 3 errors: 1) TheSeer\fDOM\Tests\fDOMDocumentTest::testCloningTriggersCreationOfNewDOMXPathInstance DOMDocument::registerNodeClass(): Couldn't fetch TheSeer\fDOM\fDOMDocument /home/sb/fDOMDocument/src/fDOMDocument.php:605 /home/sb/fDOMDocument/src/fDOMDocument.php:99 /home/sb/fDOMDocument/tests/fDOMDocument.test.php:278 2) TheSeer\fDOM\Tests\fDOMDocumentTest::testRegisteredNamespacePrefixesGetCopiedToClonedDocument DOMDocument::registerNodeClass(): Couldn't fetch TheSeer\fDOM\fDOMDocument /home/sb/fDOMDocument/src/fDOMDocument.php:605 /home/sb/fDOMDocument/src/fDOMDocument.php:99 /home/sb/fDOMDocument/tests/fDOMDocument.test.php:290 3) TheSeer\fDOM\Tests\fDOMDocumentTest::testQueryReturnsNodeFromClonedDocument DOMDocument::registerNodeClass(): Couldn't fetch TheSeer\fDOM\fDOMDocument /home/sb/fDOMDocument/src/fDOMDocument.php:605 /home/sb/fDOMDocument/src/fDOMDocument.php:99 /home/sb/fDOMDocument/tests/fDOMDocument.test.php:301 FAILURES! Tests: 120, Assertions: 165, Errors: 3. PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 21:00:02 2025 UTC |
The problem seems to get triggered by __clone() as the following stripped down example demonstrates: ----------- <?php class X extends \DOMDocument { public function __clone() { $this->registerNodeClass('DOMDocument', 'X'); } } $dom = clone (new X()); ----------- Interesting to me, but maybe totally unimportant, is the fact that it doesn't seem to matter wether the classname is hardcoded like in the above example or get_called_class() is used like in fDOMDocument's actual implementation. For what it's worth: The re-registering of the node classes is technically pointless in PHP though of course shouldn't crash. In the fDOMDocument implementation it happens only to work around an issue in hhvm (https://github.com/facebook/hhvm/issues/5412#issuecomment-106100644)