-
Notifications
You must be signed in to change notification settings - Fork 267
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Array to string conversion on exception with query parameters #601
Comments
Could you provide a simple code snippet to simplify the testing process please. |
I can't tell the exact circumstances that create the error condition. In my case, the problem occurs when a query raises an exception, but only when the code is called by PHPUnit. PHPUnit's own error handling may contribute to the problem. I could not reproduce the issue with a simple test script, other than invoking the ADODB_Exception constructor directly. Here's the backtrace that leads to the warning (last call first, i.e. the warning is raised in adodb-exceptions.inc.php:45):
The $fn parameter has the value "adodb_throw", leading to the code path in line 45. The problematic $p2 parameter contains the query parameters as an array, leading to the "array to string conversion" in that line. |
adodb-fix-exception-param-v2.patch.txt |
@hschletz thanks for your contribution. It would be nice if you could submit patches via pull requests instead of attaching diff files, it would make it easier for us to review and merge. |
@hschletz Thanks for the PR. Before merging it, I'd like to have a better understanding of the error's root cause. This is a bit difficult as you did not provide full stack trace details including function names and parameters. Nevertheless, the Can you please confirm that you are using transactions (specifically, StartTrans and CompleteTrans) in your code ? I believe the explanation for the error could be that the If so, then maybe the correct fix for the problem is to rename the diff --git a/adodb.inc.php b/adodb.inc.php
index 74c52e00..2a7c1ca9 100644
--- a/adodb.inc.php
+++ b/adodb.inc.php
@@ -302,8 +302,8 @@ if (!defined('_ADODB_LAYER')) {
//print "Errorno ($fn errno=$errno m=$errmsg) ";
$thisConnection->_transOK = false;
if ($thisConnection->_oldRaiseFn) {
- $fn = $thisConnection->_oldRaiseFn;
- $fn($dbms, $fn, $errno, $errmsg, $p1, $p2,$thisConnection);
+ $errfn = $thisConnection->_oldRaiseFn;
+ $errfn($dbms, $fn, $errno, $errmsg, $p1, $p2,$thisConnection);
}
} Can you please test and let me know ?
|
test-issue-601.php.txt Your patch works for me (applied against 5.20.16, as you guessed correctly). |
The ADODB_Exception constructor does not handle queries with parameter arrays. Patch attached.
adodb-fix-exception-param.patch.txt
The text was updated successfully, but these errors were encountered: