array to string conversion on SQLExceptions/ADODB_Exceptions

Bug #1499572 reported by Gary Leydon
6
This bug affects 1 person
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.

Robert Lyon (robertl-9)
Changed in mahara:
status: New → In Progress
importance: Undecided → Low
Revision history for this message
Mahara Bot (dev-mahara) wrote : A patch has been submitted for review

Patch for "master" branch: https://reviews.mahara.org/5402

Robert Lyon (robertl-9)
Changed in mahara:
milestone: none → 15.10.0
Aaron Wells (u-aaronw)
Changed in mahara:
milestone: 15.10.0 → 15.10.1
Revision history for this message
Mahara Bot (dev-mahara) wrote : A change has been merged

Reviewed: https://reviews.mahara.org/5402
Committed: https://git.nzoss.org.nz/mahara/mahara/commit/77faad3afbebe516706dd024a39fbbf95fa30ab9
Submitter: Robert Lyon (<email address hidden>)
Branch: master

commit 77faad3afbebe516706dd024a39fbbf95fa30ab9
Author: Gary Leydon <email address hidden>
Date: Wed Sep 30 07:57:56 2015 +1300

Bug 1499572: Avoid array to string conversion in ADODB errors

behatnotneeded: error appears in error log

Change-Id: Ic816248ee56bcae7daa1f13c768afdab92c95b23
Signed-off-by: Robert Lyon <email address hidden>

Revision history for this message
Mahara Bot (dev-mahara) wrote : A patch has been submitted for review

Patch for "15.10_STABLE" branch: https://reviews.mahara.org/6219

Revision history for this message
Mahara Bot (dev-mahara) wrote :

Patch for "15.04_STABLE" branch: https://reviews.mahara.org/6220

Revision history for this message
Mahara Bot (dev-mahara) wrote :

Patch for "1.10_STABLE" branch: https://reviews.mahara.org/6221

Revision history for this message
Mahara Bot (dev-mahara) wrote : A change has been merged

Reviewed: https://reviews.mahara.org/6219
Committed: https://git.mahara.org/mahara/mahara/commit/d4029997c8c4d0d741af6bd4cffadc264937808c
Submitter: Robert Lyon (<email address hidden>)
Branch: 15.10_STABLE

commit d4029997c8c4d0d741af6bd4cffadc264937808c
Author: Gary Leydon <email address hidden>
Date: Wed Sep 30 07:57:56 2015 +1300

Bug 1499572: Avoid array to string conversion in ADODB errors

behatnotneeded: error appears in error log

Change-Id: Ic816248ee56bcae7daa1f13c768afdab92c95b23
Signed-off-by: Robert Lyon <email address hidden>

Revision history for this message
Mahara Bot (dev-mahara) wrote :

Reviewed: https://reviews.mahara.org/6220
Committed: https://git.mahara.org/mahara/mahara/commit/541ad1e329886127cf661a74e19057d661a5906e
Submitter: Robert Lyon (<email address hidden>)
Branch: 15.04_STABLE

commit 541ad1e329886127cf661a74e19057d661a5906e
Author: Gary Leydon <email address hidden>
Date: Wed Sep 30 07:57:56 2015 +1300

Bug 1499572: Avoid array to string conversion in ADODB errors

behatnotneeded: error appears in error log

Change-Id: Ic816248ee56bcae7daa1f13c768afdab92c95b23
Signed-off-by: Robert Lyon <email address hidden>

Revision history for this message
Mahara Bot (dev-mahara) wrote :

Reviewed: https://reviews.mahara.org/6221
Committed: https://git.mahara.org/mahara/mahara/commit/3798c1053225dfd7991fd9452c78d5e5e66d3ffb
Submitter: Robert Lyon (<email address hidden>)
Branch: 1.10_STABLE

commit 3798c1053225dfd7991fd9452c78d5e5e66d3ffb
Author: Gary Leydon <email address hidden>
Date: Wed Sep 30 07:57:56 2015 +1300

Bug 1499572: Avoid array to string conversion in ADODB errors

behatnotneeded: error appears in error log

Change-Id: Ic816248ee56bcae7daa1f13c768afdab92c95b23
Signed-off-by: Robert Lyon <email address hidden>

Changed in mahara:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.