Skip to content

Commit f5e56cf

Browse files
committed
Fixed bug #72668 (Spurious warning when exception is thrown in user defined function)
1 parent 9a4c934 commit f5e56cf

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

NEWS

+2
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ PHP NEWS
7575
character). (cmb)
7676

7777
- SQLite3:
78+
. Fixed bug #72668 (Spurious warning when exception is thrown in user defined
79+
function). (Laruence)
7880
. Fixed bug #72571 (SQLite3::bindValue, SQLite3::bindParam crash). (Laruence)
7981

8082
- Standard:

ext/sqlite3/sqlite3.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -672,8 +672,10 @@ PHP_METHOD(sqlite3, querySingle)
672672
break;
673673
}
674674
default:
675+
if (!EG(exception)) {
675676
php_sqlite3_error(db_obj, "Unable to execute statement: %s", sqlite3_errmsg(db_obj->db));
676-
RETVAL_FALSE;
677+
}
678+
RETVAL_FALSE;
677679
}
678680
sqlite3_finalize(stmt);
679681
}

ext/sqlite3/tests/bug72668.phpt

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
--TEST--
2+
Bug #72668 (Spurious warning when exception is thrown in user defined function)
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded('sqlite3')) die('skip'); ?>
6+
--FILE--
7+
<?php
8+
function my_udf_md5($string) {
9+
throw new \Exception("test exception\n");
10+
}
11+
12+
$db = new SQLite3(':memory:');
13+
$db->createFunction('my_udf_md5', 'my_udf_md5');
14+
15+
try {
16+
$result = $db->querySingle('SELECT my_udf_md5("test")');
17+
var_dump($result);
18+
}
19+
catch(\Exception $e) {
20+
echo "Exception: ".$e->getMessage();
21+
}
22+
?>
23+
--EXPECT--
24+
Exception: test exception

0 commit comments

Comments
 (0)