bug49634.phpt 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. --TEST--
  2. bug #49634 (Segfault throwing an exception in a XSL registered function)
  3. --SKIPIF--
  4. <?php
  5. extension_loaded("xsl") or die("skip need ext/xsl");
  6. ?>
  7. --FILE--
  8. <?php
  9. $sXml = <<<XML
  10. <?xml version="1.0" encoding="UTF-8" ?>
  11. <root>
  12. test
  13. </root>
  14. XML;
  15. $cDIR = __DIR__;
  16. $sXsl = <<<XSL
  17. <xsl:stylesheet version="1.0"
  18. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  19. xmlns:ext="http://php.net/xsl"
  20. xsl:extension-element-prefixes="ext"
  21. exclude-result-prefixes="ext">
  22. <xsl:output encoding="UTF-8" indent="yes" method="xml" />
  23. <xsl:template match="/">
  24. <xsl:value-of select="ext:function('testFunction', document('$cDIR/bug49634.xml')/root)"/>
  25. </xsl:template>
  26. </xsl:stylesheet>
  27. XSL;
  28. function testFunction($a)
  29. {
  30. throw new Exception('Test exception.');
  31. }
  32. $domXml = new DOMDocument;
  33. $domXml->loadXML($sXml);
  34. $domXsl = new DOMDocument;
  35. $domXsl->loadXML($sXsl);
  36. for ($i = 0; $i < 10; $i++)
  37. {
  38. $xsltProcessor = new XSLTProcessor();
  39. $xsltProcessor->registerPHPFunctions(array('testFunction'));
  40. $xsltProcessor->importStyleSheet($domXsl);
  41. try {
  42. @$xsltProcessor->transformToDoc($domXml);
  43. } catch (Exception $e) {
  44. echo $e,"\n";
  45. }
  46. }
  47. ?>
  48. ===DONE===
  49. --EXPECTF--
  50. exception 'Exception' with message 'Test exception.' in %s:%d
  51. Stack trace:
  52. #0 [internal function]: testFunction(Array)
  53. #1 %s(%d): XSLTProcessor->transformToDoc(Object(DOMDocument))
  54. #2 {main}
  55. exception 'Exception' with message 'Test exception.' in %s:%d
  56. Stack trace:
  57. #0 [internal function]: testFunction(Array)
  58. #1 %s(%d): XSLTProcessor->transformToDoc(Object(DOMDocument))
  59. #2 {main}
  60. exception 'Exception' with message 'Test exception.' in %s:%d
  61. Stack trace:
  62. #0 [internal function]: testFunction(Array)
  63. #1 %s(%d): XSLTProcessor->transformToDoc(Object(DOMDocument))
  64. #2 {main}
  65. exception 'Exception' with message 'Test exception.' in %s:%d
  66. Stack trace:
  67. #0 [internal function]: testFunction(Array)
  68. #1 %s(%d): XSLTProcessor->transformToDoc(Object(DOMDocument))
  69. #2 {main}
  70. exception 'Exception' with message 'Test exception.' in %s:%d
  71. Stack trace:
  72. #0 [internal function]: testFunction(Array)
  73. #1 %s(%d): XSLTProcessor->transformToDoc(Object(DOMDocument))
  74. #2 {main}
  75. exception 'Exception' with message 'Test exception.' in %s:%d
  76. Stack trace:
  77. #0 [internal function]: testFunction(Array)
  78. #1 %s(%d): XSLTProcessor->transformToDoc(Object(DOMDocument))
  79. #2 {main}
  80. exception 'Exception' with message 'Test exception.' in %s:%d
  81. Stack trace:
  82. #0 [internal function]: testFunction(Array)
  83. #1 %s(%d): XSLTProcessor->transformToDoc(Object(DOMDocument))
  84. #2 {main}
  85. exception 'Exception' with message 'Test exception.' in %s:%d
  86. Stack trace:
  87. #0 [internal function]: testFunction(Array)
  88. #1 %s(%d): XSLTProcessor->transformToDoc(Object(DOMDocument))
  89. #2 {main}
  90. exception 'Exception' with message 'Test exception.' in %s:%d
  91. Stack trace:
  92. #0 [internal function]: testFunction(Array)
  93. #1 %s(%d): XSLTProcessor->transformToDoc(Object(DOMDocument))
  94. #2 {main}
  95. exception 'Exception' with message 'Test exception.' in %s:%d
  96. Stack trace:
  97. #0 [internal function]: testFunction(Array)
  98. #1 %s(%d): XSLTProcessor->transformToDoc(Object(DOMDocument))
  99. #2 {main}
  100. ===DONE===