1--TEST--
2DOMXPath: Calling __construct() again when functions were already registered
3--EXTENSIONS--
4dom
5--SKIPIF--
6<?php
7if (!class_exists('DOMXPath')) die('skip no xpath support');
8?>
9--FILE--
10<?php
11
12$dom = new DOMDocument;
13$dom->loadXML('<root/>');
14
15class Test {
16    public function __destruct() {
17        echo "destruct\n";
18    }
19
20    public function test() {
21        echo "test\n";
22    }
23}
24
25echo "=== First run ===\n";
26
27$xpath = new DOMXPath($dom);
28$xpath->registerNamespace('foo', 'urn:foo');
29$xpath->registerPhpFunctionNS('urn:foo', 'test', [new Test, 'test']);
30
31echo "=== Reconstruct ===\n";
32
33$xpath->__construct($dom, true);
34
35echo "=== Second run ===\n";
36
37$xpath->registerNamespace('foo', 'urn:foo');
38$xpath->query('//*[foo:test()]');
39$xpath->registerPhpFunctionNS('urn:foo', 'test', [new Test, 'test']);
40$xpath->query('//*[foo:test()]');
41
42?>
43--EXPECTF--
44=== First run ===
45=== Reconstruct ===
46destruct
47=== Second run ===
48
49Warning: DOMXPath::query(): xmlXPathCompOpEval: function test not found in %s on line %d
50
51Warning: DOMXPath::query(): Unregistered function in %s on line %d
52test
53destruct
54