Skip to content

Commit

Permalink
Add PROPEL_PDO_CONNECTION_TIMEOUT env variable
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
eddmann committed Oct 27, 2021
1 parent 2f1619f commit c3058fa
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions runtime/lib/Propel.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit c3058fa

Please sign in to comment.