1--TEST--
2libxml_set_external_entity_loader() variation: restore original handler; returning NULL
3--EXTENSIONS--
4dom
5--CLEAN--
6<?php
7@unlink(__DIR__ . "/foobar.dtd");
8?>
9--FILE--
10<?php
11chdir(__DIR__);
12$xml = <<<XML
13<!DOCTYPE foo PUBLIC "-//FOO/BAR" "foobar.dtd">
14<foo>bar</foo>
15XML;
16
17$dtd = <<<DTD
18<!ELEMENT foo (#PCDATA)>
19DTD;
20
21
22libxml_set_external_entity_loader(
23    function ($public, $system, $context) {
24        var_dump($public,$system);
25        return null;
26    }
27);
28
29$dd = new DOMDocument;
30$r = $dd->loadXML($xml);
31var_dump($dd->validate());
32
33libxml_set_external_entity_loader(NULL);
34file_put_contents(__DIR__ . "/foobar.dtd", $dtd);
35var_dump($dd->validate());
36
37echo "Done.\n";
38?>
39--EXPECTF--
40string(10) "-//FOO/BAR"
41string(%d) "%sfoobar.dtd"
42
43Warning: DOMDocument::validate(): Failed to load external entity "-//FOO/BAR" in %s on line %d
44
45Warning: DOMDocument::validate(): Could not load the external subset "foobar.dtd" in %s on line %d
46bool(false)
47bool(true)
48Done.
49