bug68760.phpt 934 B

123456789101112131415161718192021222324252627282930313233343536
  1. --TEST--
  2. Bug #68760 (Callback throws exception behaviour. Segfault in 5.6)
  3. --SKIPIF--
  4. <?php
  5. if (!extension_loaded('sqlite3')) die('skip');
  6. ?>
  7. --FILE--
  8. <?php
  9. function oopsFunction($a, $b) {
  10. echo "callback";
  11. throw new \Exception("oops");
  12. }
  13. $db = new SQLite3(":memory:");
  14. $db->exec("CREATE TABLE test (col1 string)");
  15. $db->exec("INSERT INTO test VALUES ('a1')");
  16. $db->exec("INSERT INTO test VALUES ('a10')");
  17. $db->exec("INSERT INTO test VALUES ('a2')");
  18. try {
  19. $db->createCollation('NATURAL_CMP', 'oopsFunction');
  20. $naturalSort = $db->query("SELECT col1 FROM test ORDER BY col1 COLLATE NATURAL_CMP");
  21. while ($row = $naturalSort->fetchArray()) {
  22. echo $row['col1'], "\n";
  23. }
  24. $db->close();
  25. }
  26. catch(\Exception $e) {
  27. echo "Exception: ".$e->getMessage();
  28. }
  29. ?>
  30. --EXPECTF--
  31. callback
  32. Warning: SQLite3::query(): An error occurred while invoking the compare callback in %a%ebug68760.php on line %i
  33. Exception: oops