From f573158fbbe4eaa2f717f6f8b726cbf2762b2080 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Tue, 15 Aug 2017 19:40:02 -0400 Subject: [PATCH] fix breakage caused by empty SSL_CERT options --- web/includes/database.php | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/web/includes/database.php b/web/includes/database.php index bc1242029..713621685 100644 --- a/web/includes/database.php +++ b/web/includes/database.php @@ -42,12 +42,18 @@ function dbConnect() { } try { - $dbOptions = array( - PDO::MYSQL_ATTR_SSL_CA => ZM_DB_SSL_CA_CERT, - PDO::MYSQL_ATTR_SSL_KEY => ZM_DB_SSL_CLIENT_KEY, - PDO::MYSQL_ATTR_SSL_CERT => ZM_DB_SSL_CLIENT_CERT, - ); - $dbConn = new PDO( ZM_DB_TYPE . $socket . ';dbname='.ZM_DB_NAME, ZM_DB_USER, ZM_DB_PASS, $dbOptions ); + $dbOptions = null; + if ( defined( 'ZM_DB_SSL_CA_CERT' ) and ZM_DB_SSL_CA_CERT ) { + $dbOptions = array( + PDO::MYSQL_ATTR_SSL_CA => ZM_DB_SSL_CA_CERT, + PDO::MYSQL_ATTR_SSL_KEY => ZM_DB_SSL_CLIENT_KEY, + PDO::MYSQL_ATTR_SSL_CERT => ZM_DB_SSL_CLIENT_CERT, + ); + $dbConn = new PDO( ZM_DB_TYPE . $socket . ';dbname='.ZM_DB_NAME, ZM_DB_USER, ZM_DB_PASS, $dbOptions ); + } else { + $dbConn = new PDO( ZM_DB_TYPE . $socket . ';dbname='.ZM_DB_NAME, ZM_DB_USER, ZM_DB_PASS ); + } + $dbConn->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); $dbConn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } catch(PDOException $ex ) {