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