array to string conversion on SQLExceptions/ADODB_Exceptions
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Mahara |
Fix Released
|
Low
|
Unassigned | ||
1.10 |
Fix Released
|
Low
|
Unassigned | ||
15.04 |
Fix Released
|
Low
|
Unassigned | ||
15.10 |
Fix Released
|
Low
|
Unassigned | ||
16.04 |
Fix Released
|
Low
|
Unassigned |
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.
Changed in mahara: | |
status: | New → In Progress |
importance: | Undecided → Low |
Changed in mahara: | |
milestone: | none → 15.10.0 |
Changed in mahara: | |
milestone: | 15.10.0 → 15.10.1 |
Changed in mahara: | |
status: | Fix Committed → Fix Released |
Patch for "master" branch: https:/ /reviews. mahara. org/5402