← Back to team overview

mahara-contributors team mailing list archive

[Bug 1499572] Re: array to string conversion on SQLExceptions/ADODB_Exceptions

 

** Changed in: mahara/15.10
       Status: Fix Committed => Fix Released

-- 
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:
  Fix Committed
Status in Mahara 1.10 series:
  Fix Released
Status in Mahara 15.04 series:
  Fix Released
Status in Mahara 15.10 series:
  Fix Released
Status in Mahara 16.04 series:
  Fix Committed

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


References