php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #70558 "Couldn't fetch" error in DOMDocument::registerNodeClass()
Submitted: 2015-09-23 09:39 UTC Modified: 2015-09-23 10:22 UTC
Votes:2
Avg. Score:5.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:2 (100.0%)
From: sebastian@php.net Assigned:
Status: Closed Package: DOM XML related
PHP Version: 7.0Git-2015-09-23 (Git) OS: Irrelevant
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: sebastian@php.net
New email:
PHP Version: OS:

 

 [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.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-09-23 10:20 UTC] theseer@php.net
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)
 [2015-09-23 10:22 UTC] sebastian@php.net
Thank you, Arne, for providing the minimal, self-contained, reproducing test script.
 [2015-09-23 14:02 UTC] laruence@php.net
Automatic comment on behalf of laruence@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=c87ef023aa404d310582e7a4c8c69c518a52f382
Log: Fixed Bug #70558 (&quot;Couldn't fetch&quot; error in DOMDocument::registerNodeClass())
 [2015-09-23 14:02 UTC] laruence@php.net
-Status: Open +Status: Closed
 [2015-09-29 13:10 UTC] ab@php.net
Automatic comment on behalf of laruence@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=c87ef023aa404d310582e7a4c8c69c518a52f382
Log: Fixed Bug #70558 (&quot;Couldn't fetch&quot; error in DOMDocument::registerNodeClass())
 [2016-07-20 11:36 UTC] davey@php.net
Automatic comment on behalf of laruence@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=c87ef023aa404d310582e7a4c8c69c518a52f382
Log: Fixed Bug #70558 (&quot;Couldn't fetch&quot; error in DOMDocument::registerNodeClass())
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 12:01:29 2024 UTC