Merge pull request #4282 from nextcloud/oci-connect-string

use the same oci connectstring in all code paths
This commit is contained in:
Morris Jobke 2017-04-12 13:11:00 -05:00 committed by GitHub
commit a7da2ef977
2 changed files with 36 additions and 24 deletions

View File

@ -25,6 +25,7 @@
*/
namespace OC\DB;
use Doctrine\Common\EventManager;
use Doctrine\DBAL\Configuration;
use Doctrine\DBAL\DriverManager;
@ -33,8 +34,8 @@ use Doctrine\DBAL\Event\Listeners\SQLSessionInit;
use OC\SystemConfig;
/**
* Takes care of creating and configuring Doctrine connections.
*/
* Takes care of creating and configuring Doctrine connections.
*/
class ConnectionFactory {
/**
* @var array
@ -77,7 +78,7 @@ class ConnectionFactory {
*/
public function __construct(SystemConfig $systemConfig) {
$this->config = $systemConfig;
if($this->config->getValue('mysql.utf8mb4', false)) {
if ($this->config->getValue('mysql.utf8mb4', false)) {
$this->defaultConnectionParams['mysql']['charset'] = 'utf8mb4';
}
}
@ -124,6 +125,17 @@ class ConnectionFactory {
if (isset($additionalConnectionParams['driverOptions'])) {
$additionalConnectionParams = array_merge($additionalConnectionParams, $additionalConnectionParams['driverOptions']);
}
$host = $additionalConnectionParams['host'];
$port = isset($additionalConnectionParams['port']) ? $additionalConnectionParams['port'] : null;
$dbName = $additionalConnectionParams['dbname'];
// we set the connect string as dbname and unset the host to coerce doctrine into using it as connect string
if ($host === '') {
$additionalConnectionParams['dbname'] = $dbName; // use dbname as easy connect name
} else {
$additionalConnectionParams['dbname'] = '//' . $host . (!empty($port) ? ":{$port}" : "") . '/' . $dbName;
}
unset($additionalConnectionParams['host']);
break;
case 'sqlite3':
$journalMode = $additionalConnectionParams['sqlite.journal_mode'];
@ -207,7 +219,7 @@ class ConnectionFactory {
'tablePrefix' => $connectionParams['tablePrefix']
];
if($this->config->getValue('mysql.utf8mb4', false)) {
if ($this->config->getValue('mysql.utf8mb4', false)) {
$connectionParams['defaultTableOptions'] = [
'collate' => 'utf8mb4_bin',
'charset' => 'utf8mb4',

View File

@ -149,7 +149,7 @@ class OCI extends AbstractDatabase {
if ($e_host == '') {
$easy_connect_string = $e_dbname; // use dbname as easy connect name
} else {
$easy_connect_string = '//'.$e_host.'/'.$e_dbname;
$easy_connect_string = '//' . $e_host . (!empty($e_port) ? ":{$e_port}" : "") . '/' . $e_dbname;
}
$connection = @oci_connect($this->dbUser, $this->dbPassword, $easy_connect_string);
if(!$connection) {