diff --git a/src/infrastructure/storage/lisk/LiskDAO.php b/src/infrastructure/storage/lisk/LiskDAO.php index 6db6578e1a..d21001c0a3 100644 --- a/src/infrastructure/storage/lisk/LiskDAO.php +++ b/src/infrastructure/storage/lisk/LiskDAO.php @@ -188,6 +188,7 @@ abstract class LiskDAO { private static $transactionIsolationLevel = 0; private $ephemeral = false; + private $forcedConnection; private static $connections = array(); @@ -280,6 +281,21 @@ abstract class LiskDAO { } + /** + * Force an object to use a specific connection. + * + * This overrides all connection management and forces the object to use + * a specific connection when interacting with the database. + * + * @param AphrontDatabaseConnection Connection to force this object to use. + * @task conn + */ + public function setForcedConnection(AphrontDatabaseConnection $connection) { + $this->forcedConnection = $connection; + return $this; + } + + /* -( Configuring Lisk )--------------------------------------------------- */ @@ -941,6 +957,10 @@ abstract class LiskDAO { throw new Exception("Unknown mode '{$mode}', should be 'r' or 'w'."); } + if ($this->forcedConnection) { + return $this->forcedConnection; + } + if (self::shouldIsolateAllLiskEffectsToCurrentProcess()) { $mode = 'isolate-'.$mode;