mahara-contributors team mailing list archive
-
mahara-contributors team
-
Mailing list archive
-
Message #29290
[Bug 1499572] [NEW] array to string conversion on SQLExceptions/ADODB_Exceptions
Public bug reported:
This bug has been reported from other code (#1486766) but I think the
issue is perhaps better addressed in the code for class ADODB_Exception
constructor.
I got the Array to string conversion warning in my logs when catching a
Postgres 9.4 SQLException for trying to add a record that would break a
unique key constraint. The problem was argument $p2 in ADODB_Exception
constructor was an array and when the string was created on line 43: it
generated the warning in my logs: Array to string conversion error
43: $s = "$dbms error: [$errno: $errmsg] in $fn($p1,$p2)\n";
a fix I put into my local development copy was as follows and may not be appropriate, but this worked for me
line 30 before switch statement
if is_array($p1){
$p1 = implode(":",$p1);
}
if is_array($p2){
$p2 = implode(":",$p2);
}
it could be that the p1 check is never needed. If $p2 is a monsterous
array this might be problematic as well, but this array guard means that
you don't have to hunt down every ADODB_Exception in the code to be
filtered to make sure $p2 is never an array.
** Affects: mahara
Importance: Undecided
Status: New
--
You received this bug notification because you are a member of Mahara
Contributors, which is subscribed to Mahara.
Matching subscriptions: Subscription for all Mahara Contributors -- please ask on #mahara-dev or mahara.org forum before editing or unsubscribing it!
https://bugs.launchpad.net/bugs/1499572
Title:
array to string conversion on SQLExceptions/ADODB_Exceptions
Status in Mahara:
New
Bug description:
This bug has been reported from other code (#1486766) but I think the
issue is perhaps better addressed in the code for class
ADODB_Exception constructor.
I got the Array to string conversion warning in my logs when catching
a Postgres 9.4 SQLException for trying to add a record that would
break a unique key constraint. The problem was argument $p2 in
ADODB_Exception constructor was an array and when the string was
created on line 43: it generated the warning in my logs: Array to
string conversion error
43: $s = "$dbms error: [$errno: $errmsg] in $fn($p1,$p2)\n";
a fix I put into my local development copy was as follows and may not be appropriate, but this worked for me
line 30 before switch statement
if is_array($p1){
$p1 = implode(":",$p1);
}
if is_array($p2){
$p2 = implode(":",$p2);
}
it could be that the p1 check is never needed. If $p2 is a monsterous
array this might be problematic as well, but this array guard means
that you don't have to hunt down every ADODB_Exception in the code to
be filtered to make sure $p2 is never an array.
To manage notifications about this bug go to:
https://bugs.launchpad.net/mahara/+bug/1499572/+subscriptions
Follow ups
-
[Bug 1499572] Re: array to string conversion on SQLExceptions/ADODB_Exceptions
From: Kristina Hoeppner, 2016-04-30
-
[Bug 1499572] Re: array to string conversion on SQLExceptions/ADODB_Exceptions
From: Aaron Wells, 2016-03-23
-
[Bug 1499572] Re: array to string conversion on SQLExceptions/ADODB_Exceptions
From: Son Nguyen, 2016-03-23
-
[Bug 1499572] Re: array to string conversion on SQLExceptions/ADODB_Exceptions
From: Robert Lyon, 2016-03-23
-
[Bug 1499572] A change has been merged
From: Mahara Bot, 2016-03-22
-
[Bug 1499572] A change has been merged
From: Mahara Bot, 2016-03-22
-
[Bug 1499572] Re: array to string conversion on SQLExceptions/ADODB_Exceptions
From: Robert Lyon, 2016-03-22
-
[Bug 1499572] Re: array to string conversion on SQLExceptions/ADODB_Exceptions
From: Robert Lyon, 2016-03-22
-
[Bug 1499572] A change has been merged
From: Mahara Bot, 2016-03-22
-
[Bug 1499572] A patch has been submitted for review
From: Mahara Bot, 2016-03-22
-
[Bug 1499572] A patch has been submitted for review
From: Mahara Bot, 2016-03-22
-
[Bug 1499572] A patch has been submitted for review
From: Mahara Bot, 2016-03-22
-
[Bug 1499572] Re: array to string conversion on SQLExceptions/ADODB_Exceptions
From: Aaron Wells, 2015-11-26
-
[Bug 1499572] Re: array to string conversion on SQLExceptions/ADODB_Exceptions
From: Robert Lyon, 2015-10-26
-
[Bug 1499572] A change has been merged
From: Mahara Bot, 2015-10-26
-
[Bug 1499572] Re: array to string conversion on SQLExceptions/ADODB_Exceptions
From: Robert Lyon, 2015-10-26
-
[Bug 1499572] Re: array to string conversion on SQLExceptions/ADODB_Exceptions
From: Aaron Wells, 2015-10-23
-
[Bug 1499572] Re: array to string conversion on SQLExceptions/ADODB_Exceptions
From: Robert Lyon, 2015-09-29
-
[Bug 1499572] A patch has been submitted for review
From: Mahara Bot, 2015-09-29