com php-src: Stop trying to call the callback after it has thrown an exception. Also, as an exception has been thrown, there is no need to have a
separate error message.: ext/sqlite3/sqlite3.c ext/sqlite3/tests/bug68760.phpt

From: Date: Mon, 16 Feb 2015 21:45:21 +0000
Subject: com php-src: Stop trying to call the callback after it has thrown an exception. Also, as an exception has been thrown, there is no need to have a
separate error message.: ext/sqlite3/sqlite3.c ext/sqlite3/tests/bug68760.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-85769@lists.php.net to get a copy of this message
Commit: 44f15b068d40eb3750864af54126ef25b238e412 Author: Danack <Danack@basereality.com> Mon, 16 Feb 2015 21:45:21 +0000 Parents: 94e2002de5dc275533922f1753b9a9e666fee404 Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=44f15b068d40eb3750864af54126ef25b238e412 Log: Stop trying to call the callback after it has thrown an exception. Also, as an exception has been thrown, there is no need to have a separate error message. Changed paths: M ext/sqlite3/sqlite3.c M ext/sqlite3/tests/bug68760.phpt Diff: diff --git a/ext/sqlite3/sqlite3.c b/ext/sqlite3/sqlite3.c index 556f786..93a865e 100644 --- a/ext/sqlite3/sqlite3.c +++ b/ext/sqlite3/sqlite3.c @@ -860,18 +860,23 @@ static int php_sqlite3_callback_compare(void *coll, int a_len, const void *a, in collation->fci.fci.params = zargs; - if ((ret = zend_call_function(&collation->fci.fci, &collation->fci.fcc)) == FAILURE) { - php_error_docref(NULL, E_WARNING, "An error occurred while invoking the compare callback"); + if (!EG(exception)) { + //Exception occurred on previous callback. Don't attempt to call function + if ((ret = zend_call_function(&collation->fci.fci, &collation->fci.fcc)) == FAILURE) { + php_error_docref(NULL, E_WARNING, "An error occurred while invoking the compare callback"); + } } zval_ptr_dtor(&zargs[0]); zval_ptr_dtor(&zargs[1]); efree(zargs); - //retval ought to contain a ZVAL_LONG by now - // (the result of a comparison, i.e. most likely -1, 0, or 1) - //I suppose we could accept any scalar return type, though. - if (Z_TYPE(retval) != IS_LONG){ + if (EG(exception)) { + ret = 0; + } else if (Z_TYPE(retval) != IS_LONG){ + //retval ought to contain a ZVAL_LONG by now + // (the result of a comparison, i..e. most likely -1, 0, or 1) + //I suppose we could accept any scalar return type, though. php_error_docref(NULL, E_WARNING, "An error occurred while invoking the compare callback (invalid return type). Collation behaviour is undefined."); }else{ ret = Z_LVAL(retval); diff --git a/ext/sqlite3/tests/bug68760.phpt b/ext/sqlite3/tests/bug68760.phpt index 5eb7d84..562fa48 100644 --- a/ext/sqlite3/tests/bug68760..phpt +++ b/ext/sqlite3/tests/bug68760.phpt @@ -1,9 +1,9 @@ --TEST-- -Bug #68760 (Callback throws exception behaviour. Segfault in 5.6) +Bug #68760 (Callback throws exception behaviour.) --FILE-- <?php function oopsFunction($a, $b) { - echo "callback"; + echo "callback".PHP_EOL; throw new \Exception("oops"); } @@ -27,6 +27,5 @@ catch(\Exception $e) { ?> --EXPECTF-- callback -Warning: SQLite3::query(): An error occurred while invoking the compare callback in %a/bug68760.php on line %i Exception: oops

« previous php.cvs (#85769) next »