com php-src: Further fixes wrt. bug #72668: ext/sqlite3/sqlite3.c ext/sqlite3/tests/bug72668.phpt

From: Date: Mon, 25 Jul 2016 15:03:10 +0000
Subject: com php-src: Further fixes wrt. bug #72668: ext/sqlite3/sqlite3.c ext/sqlite3/tests/bug72668.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-93391@lists.php.net to get a copy of this message
Commit: 64e3e932fc38dc7e59805dfb28acae173503018b Author: Christoph M. Becker <cmb@php.net> Mon, 25 Jul 2016 17:03:10 +0200 Parents: 0c34d515f16963922bed749c9320a99043c06722 Branches: PHP-5.6 PHP-7.0 PHP-7.1 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=64e3e932fc38dc7e59805dfb28acae173503018b Log: Further fixes wrt. bug #72668 Not only SQLite3::querySingle(), but also SQLite3::query() and SQLite3Stmt::execute() were affected. Bugs: https://bugs..php.net/72668 Changed paths: M ext/sqlite3/sqlite3.c A ext/sqlite3/tests/bug72668.phpt Diff: diff --git a/ext/sqlite3/sqlite3.c b/ext/sqlite3/sqlite3.c index 4513b77..c901e53 100644 --- a/ext/sqlite3/sqlite3.c +++ b/ext/sqlite3/sqlite3.c @@ -578,7 +578,9 @@ PHP_METHOD(sqlite3, query) break; } default: - php_sqlite3_error(db_obj, "Unable to execute statement: %s", sqlite3_errmsg(db_obj->db)); + if (!EG(exception)) { + php_sqlite3_error(db_obj, "Unable to execute statement: %s", sqlite3_errmsg(db_obj->db)); + } sqlite3_finalize(stmt_obj->stmt); stmt_obj->initialised = 0; zval_dtor(return_value); @@ -690,7 +692,9 @@ PHP_METHOD(sqlite3, querySingle) break; } default: - php_sqlite3_error(db_obj, "Unable to execute statement: %s", sqlite3_errmsg(db_obj->db)); + if (!EG(exception)) { + php_sqlite3_error(db_obj, "Unable to execute statement: %s", sqlite3_errmsg(db_obj->db)); + } RETVAL_FALSE; } sqlite3_finalize(stmt); @@ -1637,7 +1641,9 @@ PHP_METHOD(sqlite3stmt, execute) sqlite3_reset(stmt_obj->stmt); default: - php_sqlite3_error(stmt_obj->db_obj, "Unable to execute statement: %s", sqlite3_errmsg(sqlite3_db_handle(stmt_obj->stmt))); + if (!EG(exception)) { + php_sqlite3_error(stmt_obj->db_obj, "Unable to execute statement: %s", sqlite3_errmsg(sqlite3_db_handle(stmt_obj->stmt))); + } zval_dtor(return_value); RETURN_FALSE; } diff --git a/ext/sqlite3/tests/bug72668.phpt b/ext/sqlite3/tests/bug72668.phpt new file mode 100644 index 0000000..2845fa0 --- /dev/null +++ b/ext/sqlite3/tests/bug72668.phpt @@ -0,0 +1,41 @@ +--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->query('SELECT my_udf_md5("test")'); + var_dump($result); +} +catch(\Exception $e) { + echo "Exception: ".$e->getMessage(); +} +try { + $result = $db->querySingle('SELECT my_udf_md5("test")'); + var_dump($result); +} +catch(\Exception $e) { + echo "Exception: ".$e->getMessage(); +} +$statement = $db->prepare('SELECT my_udf_md5("test")'); +try { + $result = $statement->execute(); + var_dump($result); +} +catch(\Exception $e) { + echo "Exception: ".$e->getMessage(); +} +?> +--EXPECT-- +Exception: test exception +Exception: test exception +Exception: test exception

« previous php.cvs (#93391) next »