Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Connection::$isConnected #4092

Merged
merged 1 commit into from
Jun 19, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 5 additions & 16 deletions lib/Doctrine/DBAL/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,6 @@ class Connection implements DriverConnection
/** @var ExpressionBuilder */
protected $_expr;

/**
* Whether or not a connection has been established.
*
* @var bool
*/
private $isConnected = false;

/**
* The current auto-commit mode of this connection.
*
Expand Down Expand Up @@ -192,8 +185,7 @@ public function __construct(
$this->params = $params;

if (isset($params['pdo'])) {
$this->_conn = $params['pdo'];
$this->isConnected = true;
$this->_conn = $params['pdo'];
unset($this->params['pdo']);
}

Expand Down Expand Up @@ -356,16 +348,15 @@ public function getExpressionBuilder()
*/
public function connect()
{
if ($this->isConnected) {
if ($this->_conn !== null) {
return false;
}

$driverOptions = $this->params['driverOptions'] ?? [];
$user = $this->params['user'] ?? null;
$password = $this->params['password'] ?? null;

$this->_conn = $this->_driver->connect($this->params, $user, $password, $driverOptions);
$this->isConnected = true;
$this->_conn = $this->_driver->connect($this->params, $user, $password, $driverOptions);

$this->transactionNestingLevel = 0;

Expand Down Expand Up @@ -524,7 +515,7 @@ public function setAutoCommit($autoCommit)
$this->autoCommit = $autoCommit;

// Commit all currently active transactions if any when switching auto-commit mode.
if ($this->isConnected !== true || $this->transactionNestingLevel === 0) {
if ($this->_conn === null || $this->transactionNestingLevel === 0) {
return;
}

Expand Down Expand Up @@ -689,7 +680,7 @@ public function fetchOne(string $query, array $params = [], array $types = [])
*/
public function isConnected()
{
return $this->isConnected;
return $this->_conn !== null;
}

/**
Expand Down Expand Up @@ -771,8 +762,6 @@ public function delete($tableExpression, array $identifier, array $types = [])
public function close()
{
$this->_conn = null;

$this->isConnected = false;
}

/**
Expand Down