]> granicus.if.org Git - php/commitdiff
Fixed bug #72668 (Spurious warning when exception is thrown in user defined function)
authorXinchen Hui <laruence@gmail.com>
Mon, 25 Jul 2016 12:28:39 +0000 (20:28 +0800)
committerXinchen Hui <laruence@gmail.com>
Mon, 25 Jul 2016 12:28:39 +0000 (20:28 +0800)
NEWS
ext/sqlite3/sqlite3.c
ext/sqlite3/tests/bug72668.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index 31d8ee797008e62f2c1cc7a7c8f1817ad57926cd..6d1b69e49f7d651fba7e5adf568f8e321c88ba9b 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -75,6 +75,8 @@ PHP                                                                        NEWS
     character). (cmb)
 
 - SQLite3:
+  . Fixed bug #72668 (Spurious warning when exception is thrown in user defined
+    function). (Laruence)
   . Fixed bug #72571 (SQLite3::bindValue, SQLite3::bindParam crash). (Laruence)
 
 - Standard:
index 0e0ef09d2570e57517bc280468b57183b1355a0a..c9b6686689e38cf89217218915082b92ac5b7062 100644 (file)
@@ -672,8 +672,10 @@ PHP_METHOD(sqlite3, querySingle)
                        break;
                }
                default:
+               if (!EG(exception)) {
                        php_sqlite3_error(db_obj, "Unable to execute statement: %s", sqlite3_errmsg(db_obj->db));
-                       RETVAL_FALSE;
+               }
+               RETVAL_FALSE;
        }
        sqlite3_finalize(stmt);
 }
diff --git a/ext/sqlite3/tests/bug72668.phpt b/ext/sqlite3/tests/bug72668.phpt
new file mode 100644 (file)
index 0000000..ccb238f
--- /dev/null
@@ -0,0 +1,24 @@
+--TEST--
+Bug #72668 (Spurious warning when exception is thrown in user defined function)
+--SKIPIF--
+<?php
+if (!extension_loaded('sqlite3')) die('skip'); ?>
+--FILE--
+<?php
+function my_udf_md5($string) {
+           throw new \Exception("test exception\n");
+}
+
+$db = new SQLite3(':memory:');
+$db->createFunction('my_udf_md5', 'my_udf_md5');
+
+try {
+           $result = $db->querySingle('SELECT my_udf_md5("test")');
+                   var_dump($result);
+}
+catch(\Exception $e) {
+           echo "Exception: ".$e->getMessage();
+}
+?>
+--EXPECT--
+Exception: test exception