bug49634.phpt 2.8 KB

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