Skip to content
Snippets Groups Projects
Commit cbffaff7 authored by Lukas Reschke's avatar Lukas Reschke
Browse files

Merge pull request #13480 from owncloud/mysql-autocommit

set MySQL autocommit on connection setup
parents 6c1e13a6 baefefbb
No related branches found
No related tags found
No related merge requests found
...@@ -7,6 +7,9 @@ ...@@ -7,6 +7,9 @@
*/ */
namespace OC\DB; namespace OC\DB;
use Doctrine\DBAL\Event\Listeners\OracleSessionInit;
use Doctrine\DBAL\Event\Listeners\SQLSessionInit;
use Doctrine\DBAL\Event\Listeners\MysqlSessionInit;
/** /**
* Takes care of creating and configuring Doctrine connections. * Takes care of creating and configuring Doctrine connections.
...@@ -84,10 +87,12 @@ class ConnectionFactory { ...@@ -84,10 +87,12 @@ class ConnectionFactory {
case 'mysql': case 'mysql':
// Send "SET NAMES utf8". Only required on PHP 5.3 below 5.3.6. // Send "SET NAMES utf8". Only required on PHP 5.3 below 5.3.6.
// See http://stackoverflow.com/questions/4361459/php-pdo-charset-set-names#4361485 // See http://stackoverflow.com/questions/4361459/php-pdo-charset-set-names#4361485
$eventManager->addEventSubscriber(new \Doctrine\DBAL\Event\Listeners\MysqlSessionInit); $eventManager->addEventSubscriber(new MysqlSessionInit);
$eventManager->addEventSubscriber(
new SQLSessionInit("SET SESSION AUTOCOMMIT=1"));
break; break;
case 'oci': case 'oci':
$eventManager->addEventSubscriber(new \Doctrine\DBAL\Event\Listeners\OracleSessionInit); $eventManager->addEventSubscriber(new OracleSessionInit);
break; break;
case 'sqlite3': case 'sqlite3':
$journalMode = $additionalConnectionParams['sqlite.journal_mode']; $journalMode = $additionalConnectionParams['sqlite.journal_mode'];
...@@ -136,8 +141,8 @@ class ConnectionFactory { ...@@ -136,8 +141,8 @@ class ConnectionFactory {
$name = $config->getValue('dbname', 'owncloud'); $name = $config->getValue('dbname', 'owncloud');
if ($this->normalizeType($type) === 'sqlite3') { if ($this->normalizeType($type) === 'sqlite3') {
$datadir = $config->getValue("datadirectory", \OC::$SERVERROOT . '/data'); $dataDir = $config->getValue("datadirectory", \OC::$SERVERROOT . '/data');
$connectionParams['path'] = $datadir . '/' . $name . '.db'; $connectionParams['path'] = $dataDir . '/' . $name . '.db';
} else { } else {
$host = $config->getValue('dbhost', ''); $host = $config->getValue('dbhost', '');
if (strpos($host, ':')) { if (strpos($host, ':')) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment