1
0
Fork 0
mirror of synced 2024-06-27 02:31:04 +12:00

Connection persistency

This commit is contained in:
Eldad Fux 2020-07-02 12:02:43 +03:00
parent 5a32260dd2
commit 457fffc692
5 changed files with 11 additions and 8 deletions

View file

@ -305,7 +305,7 @@ App::error(function ($error, $utopia, $request, $response, $project) {
$message = 'Server Error';
}
$_SERVER = []; // Reset before reporting to error log to avoid keys being compromised
//$_SERVER = []; // Reset before reporting to error log to avoid keys being compromised
$output = ((App::isDevelopment())) ? [
'message' => $error->getMessage(),

View file

@ -122,7 +122,6 @@ $register->set('statsd', function () { // Register DB connection
});
$register->set('cache', function () { // Register cache connection
$redis = new Redis();
$redis->pconnect(App::getEnv('_APP_REDIS_HOST', ''),
App::getEnv('_APP_REDIS_PORT', ''));

View file

@ -1,7 +1,5 @@
<?php
use Utopia\Locale\Locale;
$protocol = $this->getParam('protocol', '');
$domain = $this->getParam('domain', '');
$platforms = $this->getParam('platforms', []);

View file

@ -51,7 +51,7 @@ class PDO
public function prepare($statement, array $driver_options = [])
{
return new PDOStatement($this->pdo, $this->pdo->prepare($statement, $driver_options));
return new PDOStatement($this, $this->pdo->prepare($statement, $driver_options));
}
public function quote($string, $parameter_type = PDONative::PARAM_STR)

View file

@ -8,7 +8,7 @@ use PDOStatement as PDOStatementNative;
class PDOStatement
{
/**
* @var PDONative
* @var PDO
*/
protected $pdo;
@ -17,7 +17,7 @@ class PDOStatement
*/
protected $PDOStatement;
public function __construct(PDONative &$pdo, PDOStatementNative $PDOStatement)
public function __construct(PDO &$pdo, PDOStatementNative $PDOStatement)
{
$this->pdo = $pdo;
$this->PDOStatement = $PDOStatement;
@ -46,7 +46,13 @@ class PDOStatement
public function execute($input_parameters = null)
{
$result = $this->PDOStatement->execute($input_parameters);
try {
$result = $this->PDOStatement->execute($input_parameters);
} catch (\Throwable $th) {
// throw new Exception('My Error: ' .$th->getMessage());
$this->pdo->reconnect();
$result = $this->PDOStatement->execute($input_parameters);
}
return $result;
}