From: Brian Wolff Date: Sat, 1 Mar 2014 03:55:00 +0000 (-0400) Subject: Fix __toString method of DatabaseMysqli X-Git-Tag: 1.31.0-rc.0~16777 X-Git-Url: http://git.cyclocoop.org//%27http:/jquery.khurshid.com/ifixpng.php/%27?a=commitdiff_plain;h=c393aa71e3e8b55e5459bceb16eb71a48a26c877;p=lhc%2Fweb%2Fwiklou.git Fix __toString method of DatabaseMysqli The superclass was casting mConn to string. For Mysql class this is just the resource number. However for mysqli objects, that is a fatal. thread_id seemed like the most convinenent id-ish number to return instead. Only really noticeable if you have $wgDebugTransactions = true; Change-Id: I014bb7ab81d18c5bd07a267939b66a0a6161eb8d --- diff --git a/includes/db/DatabaseMysqli.php b/includes/db/DatabaseMysqli.php index e202f8a926..635909cc65 100644 --- a/includes/db/DatabaseMysqli.php +++ b/includes/db/DatabaseMysqli.php @@ -281,4 +281,18 @@ class DatabaseMysqli extends DatabaseMysqlBase { protected function mysqlPing() { return $this->mConn->ping(); } + + /** + * Give an id for the connection + * + * mysql driver used resource id, but mysqli objects cannot be cast to string. + */ + public function __toString() { + if ( $this->mConn instanceof Mysqli ) { + return (string)$this->mConn->thread_id; + } else { + // mConn might be false or something. + return (string)$this->mConn; + } + } }