From c3058fa8b7a130b8f997be4093d69c77fc968f63 Mon Sep 17 00:00:00 2001 From: Edd Mann Date: Wed, 27 Oct 2021 14:27:07 +0100 Subject: [PATCH] Add `PROPEL_PDO_CONNECTION_TIMEOUT` env variable With the PropelBundle Symfony integration there is no way to correctly specify PDO attributes. The configuration schema requires a scalar value, however Propel requires a keyed 'value' array. This allows us to specify the timeout within the runtime environment (i.e for Lambda). --- runtime/lib/Propel.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/runtime/lib/Propel.php b/runtime/lib/Propel.php index 9a6ac2e9d..deac8b765 100644 --- a/runtime/lib/Propel.php +++ b/runtime/lib/Propel.php @@ -686,6 +686,13 @@ public static function initConnection($conparams, $name, $defaultClass = Propel: $con = new $classname($dsn, $user, $password, $driver_options); $con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $con->setAttribute(PropelPDO::PROPEL_ATTR_CONNECTION_NAME, $name); + + // With the PropelBundle Symfony integration there is no way to correctly specify PDO attributes. + // The configuration schema requires a scalar value, however Propel requires a keyed 'value' array. + // This allows us to specify the timeout within the runtime environment (i.e for Lambda). + if ($connectionTimeout = \getenv('PROPEL_PDO_CONNECTION_TIMEOUT')) { + $con->setAttribute(\PDO::ATTR_TIMEOUT, $connectionTimeout); + } } catch (PDOException $e) { throw new PropelException("Unable to open PDO connection", $e); }