Skip to content

Commit 6c72d65

Browse files
Fix Adapter\Pdo\Mysql::closeConnection on non-default ports
Fixing Magento\Framework\DB\Adapter\Pdo\Mysql::closeConnection when the port is a non-default port. When we are using a non-default port for the database, and closeConnection() method is called, this prevents automatic reconnection from working. This is because during the connection, we move the port into $this->_config['port']. The closeConnection() is not called in normal Magento usage. However, it is always called when running the integration tests. This means that that you cannot use integration tests with a Mysql server on a non-default port. Steps to reproduce the error that this bugs fixes: 1. Configure a Mysql server using a custom port. 2. Configure Magento integration tests to use this database. 3. Try to run integration tests. Expected Result: Integration tests pass. Actual Result: Integration tests fail with errors because they use closeConnection() which loses the port configuration.
1 parent acfafe0 commit 6c72d65

File tree

1 file changed

+15
-0
lines changed
  • lib/internal/Magento/Framework/DB/Adapter/Pdo

1 file changed

+15
-0
lines changed

lib/internal/Magento/Framework/DB/Adapter/Pdo/Mysql.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4030,4 +4030,19 @@ public function getSchemaListener()
40304030
}
40314031
return $this->schemaListener;
40324032
}
4033+
4034+
/**
4035+
* Closes the connection.
4036+
*/
4037+
public function closeConnection()
4038+
{
4039+
/**
4040+
* _connect() function does not allow port parameter, so put the port back with the host
4041+
*/
4042+
if (!empty($this->_config['port'])) {
4043+
$this->_config['host'] = implode(':', [$this->_config['host'], $this->_config['port']]);
4044+
unset($this->_config['port']);
4045+
}
4046+
parent::closeConnection();
4047+
}
40334048
}

0 commit comments

Comments
 (0)