From 651be2a4cfc609cdd3bf1a63c82a0b6a3798ae93 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Sat, 20 Feb 2016 18:16:21 +0000 Subject: [PATCH] removing for some of our ADOdb patches --- api/src/Vfs/Sqlfs/StreamWrapper.php | 21 ++++++++++----------- phpgwapi/inc/class.egw_db.inc.php | 20 +++++++++++++++++--- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/api/src/Vfs/Sqlfs/StreamWrapper.php b/api/src/Vfs/Sqlfs/StreamWrapper.php index efbfd84368..5c16198bfb 100644 --- a/api/src/Vfs/Sqlfs/StreamWrapper.php +++ b/api/src/Vfs/Sqlfs/StreamWrapper.php @@ -1685,6 +1685,16 @@ class StreamWrapper implements Vfs\StreamWrapperIface } $pdo_available = true; } + // set client charset of the connection + switch(self::$pdo_type) + { + case 'mysql': + $dsn .= ';charset=utf8'; + break; + case 'pgsql': + $query = "SET NAMES 'utf-8'"; + break; + } try { self::$pdo = new \PDO($dsn,$egw_db->User,$egw_db->Password,array( \PDO::ATTR_ERRMODE=>\PDO::ERRMODE_EXCEPTION, @@ -1696,17 +1706,6 @@ class StreamWrapper implements Vfs\StreamWrapperIface // Exception reveals password, so we ignore the exception and connect again without pw, to get the right exception without pw self::$pdo = new \PDO($dsn,$egw_db->User,'$egw_db->Password'); } - // set client charset of the connection - $charset = translation::charset(); - switch(self::$pdo_type) - { - case 'mysql': - if (isset($egw_db->Link_ID->charset2mysql[$charset])) $charset = $egw_db->Link_ID->charset2mysql[$charset]; - // fall throught - case 'pgsql': - $query = "SET NAMES '$charset'"; - break; - } if ($query) { self::$pdo->exec($query); diff --git a/phpgwapi/inc/class.egw_db.inc.php b/phpgwapi/inc/class.egw_db.inc.php index ea9e7c3d8f..64d2afcc32 100644 --- a/phpgwapi/inc/class.egw_db.inc.php +++ b/phpgwapi/inc/class.egw_db.inc.php @@ -7,7 +7,7 @@ * @package api * @subpackage db * @author Ralf Becker - * @copyright (c) 2003-14 by Ralf Becker + * @copyright (c) 2003-16 by Ralf Becker * @version $Id$ */ @@ -487,7 +487,16 @@ class egw_db break; case 'mysqlt': - $php_extension = 'mysql'; // you can use $this->setupType to determine if it's mysqlt or mysql + case 'mysql': + // if mysqli is available silently switch to it, mysql extension is deprecated and no longer available in php7+ + if (check_load_extension('mysqli')) + { + $php_extension = $Type = 'mysqli'; + } + else + { + $php_extension = 'mysql'; // you can use $this->setupType to determine if it's mysqlt or mysql + } // fall through case 'mysqli': $this->Type = 'mysql'; // need to be "mysql", so apps can check just for "mysql"! @@ -521,6 +530,11 @@ class egw_db { throw new egw_exception_db_connection("No ADOdb support for '$Type' ($this->Type) !!!"); } + if ($Type == 'mysqli') + { + // set a connection timeout of 1 second, to allow quicker failover to other db-nodes (default is 20s) + $this->Link_ID->setConnectionParameter(MYSQLI_OPT_CONNECT_TIMEOUT, 1); + } $connect = $GLOBALS['egw_info']['server']['db_persistent'] ? 'PConnect' : 'Connect'; if (($Ok = $this->Link_ID->$connect($Host, $User, $Password, $Database))) { @@ -549,7 +563,7 @@ class egw_db ini_set('mssql.sizelimit',2147483647); } // set our default charset - $this->Link_ID->SetCharSet('utf-8'); + $this->Link_ID->SetCharSet($this->Type == 'mysql' ? 'utf8' : 'utf-8'); $new_connection = true; }