File tree Expand file tree Collapse file tree 2 files changed +50
-3
lines changed Expand file tree Collapse file tree 2 files changed +50
-3
lines changed Original file line number Diff line number Diff line change @@ -578,7 +578,9 @@ PHP_METHOD(sqlite3, query)
578
578
break ;
579
579
}
580
580
default :
581
- php_sqlite3_error (db_obj , "Unable to execute statement: %s" , sqlite3_errmsg (db_obj -> db ));
581
+ if (!EG (exception )) {
582
+ php_sqlite3_error (db_obj , "Unable to execute statement: %s" , sqlite3_errmsg (db_obj -> db ));
583
+ }
582
584
sqlite3_finalize (stmt_obj -> stmt );
583
585
stmt_obj -> initialised = 0 ;
584
586
zval_dtor (return_value );
@@ -690,7 +692,9 @@ PHP_METHOD(sqlite3, querySingle)
690
692
break ;
691
693
}
692
694
default :
693
- php_sqlite3_error (db_obj , "Unable to execute statement: %s" , sqlite3_errmsg (db_obj -> db ));
695
+ if (!EG (exception )) {
696
+ php_sqlite3_error (db_obj , "Unable to execute statement: %s" , sqlite3_errmsg (db_obj -> db ));
697
+ }
694
698
RETVAL_FALSE ;
695
699
}
696
700
sqlite3_finalize (stmt );
@@ -1637,7 +1641,9 @@ PHP_METHOD(sqlite3stmt, execute)
1637
1641
sqlite3_reset (stmt_obj -> stmt );
1638
1642
1639
1643
default :
1640
- php_sqlite3_error (stmt_obj -> db_obj , "Unable to execute statement: %s" , sqlite3_errmsg (sqlite3_db_handle (stmt_obj -> stmt )));
1644
+ if (!EG (exception )) {
1645
+ php_sqlite3_error (stmt_obj -> db_obj , "Unable to execute statement: %s" , sqlite3_errmsg (sqlite3_db_handle (stmt_obj -> stmt )));
1646
+ }
1641
1647
zval_dtor (return_value );
1642
1648
RETURN_FALSE ;
1643
1649
}
Original file line number Diff line number Diff line change
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 ->query ('SELECT my_udf_md5("test") ' );
17
+ var_dump ($ result );
18
+ }
19
+ catch (\Exception $ e ) {
20
+ echo "Exception: " .$ e ->getMessage ();
21
+ }
22
+ try {
23
+ $ result = $ db ->querySingle ('SELECT my_udf_md5("test") ' );
24
+ var_dump ($ result );
25
+ }
26
+ catch (\Exception $ e ) {
27
+ echo "Exception: " .$ e ->getMessage ();
28
+ }
29
+ $ statement = $ db ->prepare ('SELECT my_udf_md5("test") ' );
30
+ try {
31
+ $ result = $ statement ->execute ();
32
+ var_dump ($ result );
33
+ }
34
+ catch (\Exception $ e ) {
35
+ echo "Exception: " .$ e ->getMessage ();
36
+ }
37
+ ?>
38
+ --EXPECT--
39
+ Exception: test exception
40
+ Exception: test exception
41
+ Exception: test exception
You can’t perform that action at this time.
0 commit comments