Don't open a second (actually, third) DB connection [MAILPOET-966]
This commit is contained in:
committed by
pavel-mailpoet
parent
fb1a3a80ff
commit
605df7dff1
@@ -42,25 +42,21 @@ class Database {
|
|||||||
$driver_options[] = $character_set;
|
$driver_options[] = $character_set;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
ORM::configure('driver_options', array(
|
||||||
* Rethrow PDOExceptions to prevent exposing sensitive data in stack traces
|
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET ' . implode(', ', $driver_options)
|
||||||
*/
|
));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$current_options = ORM::for_table("")
|
$current_options = ORM::for_table("")
|
||||||
->raw_query('SELECT @@session.wait_timeout as wait_timeout')
|
->raw_query('SELECT @@session.wait_timeout as wait_timeout')
|
||||||
->findOne();
|
->findOne();
|
||||||
|
if($current_options && (int)$current_options->wait_timeout < $this->driver_option_wait_timeout) {
|
||||||
|
ORM::raw_execute('SET SESSION wait_timeout = ' . $this->driver_option_wait_timeout);
|
||||||
|
}
|
||||||
} catch (\PDOException $e) {
|
} catch (\PDOException $e) {
|
||||||
|
// Rethrow PDOExceptions to prevent exposing sensitive data in stack traces
|
||||||
throw new \Exception($e->getMessage());
|
throw new \Exception($e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
if($current_options && (int)$current_options->wait_timeout < $this->driver_option_wait_timeout) {
|
|
||||||
$driver_options[] = 'SESSION wait_timeout = ' . $this->driver_option_wait_timeout;
|
|
||||||
}
|
|
||||||
// reset the database
|
|
||||||
ORM::set_db(null);
|
|
||||||
ORM::configure('driver_options', array(
|
|
||||||
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET ' . implode(', ', $driver_options)
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function defineTables() {
|
function defineTables() {
|
||||||
|
Reference in New Issue
Block a user