1--TEST--
2Bug #71540 (NULL pointer dereference in xsl_ext_function_php())
3--EXTENSIONS--
4xsl
5--SKIPIF--
6<?php
7if (LIBXML_VERSION >= 20903) die('skip this test is for PHP linked with libxml2 < 2.9.3 only')
8?>
9--FILE--
10<?php
11$xml = <<<EOB
12<allusers>
13 <user>
14  <uid>bob</uid>
15 </user>
16</allusers>
17EOB;
18$xsl = <<<EOB
19<?xml version="1.0" encoding="UTF-8"?>
20<xsl:stylesheet version="1.0"
21     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
22     xmlns:php="http://php.net/xsl">
23<xsl:output method="html" encoding="utf-8" indent="yes"/>
24 <xsl:template match="allusers">
25  <html><body>
26    <h2>Users</h2>
27    <table>
28    <xsl:for-each select="user">
29      <tr><td>
30        <xsl:value-of
31             select="php:function('test',uid,test(test))"/>
32      </td></tr>
33    </xsl:for-each>
34    </table>
35  </body></html>
36 </xsl:template>
37</xsl:stylesheet>
38EOB;
39
40$xmldoc = new DOMDocument();
41$xmldoc->loadXML($xml);
42$xsldoc = new DOMDocument();
43$xsldoc->loadXML($xsl);
44
45$proc = new XSLTProcessor();
46$proc->registerPHPFunctions();
47$proc->importStyleSheet($xsldoc);
48echo $proc->transformToXML($xmldoc);
49?>
50DONE
51--EXPECTF--
52Warning: XSLTProcessor::transformToXml(): xmlXPathCompOpEval: function test not found in %sbug71540.php on line %d
53
54Warning: XSLTProcessor::transformToXml(): Unregistered function in %sbug71540.php on line %d
55
56Warning: XSLTProcessor::transformToXml(): Stack usage error in %sbug71540.php on line %d
57
58Warning: XSLTProcessor::transformToXml(): Stack usage error in %sbug71540.php on line %d
59
60Warning: XSLTProcessor::transformToXml(): Handler name must be a string in %sbug71540.php on line %d
61
62Warning: XSLTProcessor::transformToXml(): xmlXPathCompiledEval: 2 objects left on the stack. in %sbug71540.php on line %d
63
64Warning: XSLTProcessor::transformToXml(): runtime error: file %s line 13 element value-of in %sbug71540.php on line %d
65
66Warning: XSLTProcessor::transformToXml(): XPath evaluation returned no result. in %sbug71540.php on line %d
67<html xmlns:php="http://php.net/xsl"><body>
68<h2>Users</h2>
69<table><tr><td></td></tr></table>
70</body></html>
71DONE
72