DoctrineMySQLComeBack 2.0.0: DBAL 3 support
This is a republished tag announcement for
facile-it/doctrine-mysql-come-back
. You can find the release here.
The facile-it/doctrine-mysql-come-back
was written long time ago by my colleague Luca Boeri, in an attempt to solve the infamous “MySQL server has gone away” error, and similar issues. It’s a simple Doctrine DBAL driver wrapper that catches relevant exceptions from the driver and attempts to reconnect to the database; this is pretty useful if your PHP script is doing something else between queries, and an aggressive timeout from the database truncates the connection in the meantime, due to the prolonged inactivity.
Since more than a year ago, I was personally wrestling with how to upgrade this library to DBAL v3, because this library was holding back the DBAL upgrade in many of my company’s PHP projects. This upgrade was troublesome because DBAL v3 had many changes that forced us to revise the library’s approach: main hurdles were that driver classes are now final
, and the internal flow has changed a bit, mainly due to deprecations of some methods. After some back and forth, I was able to tag a BETA version, and with BETA4 I was finally able to confidently upgrade a couple of our projects in production, which are now running smoothly on DBAL 3.6 since a month or two.
So, with great pride, I’m now happy to share that I was able to tag a stable 2.0.0 tag! Here’s the full changelog:
Full changelog
This is the final, stable release of the new version of this library, supporting DBAL 3.6+; unfortunately, DBAL 3.0 to 3.5 is unsupported (but upgrading to 3.6 should not be an issue).
If you’re upgrading from a 1.x version, please refer to the UPGRADE-2.0.md document.
The version has no changes from 2.0.0-BETA4; the following is the detailed changelog from the 1.x series:
Added
- Support DBAL v3.6+
- Add
GoneAwayDetector
interface andMySQLGoneAwayDetector
class implementation - Add
setGoneAwayDetector
method to the connections - Add handling of AWS MySQL RDS connection loss
- Add validation to
x_reconnect_attempts
- Add mutation testing with Infection
Changed
- Change
Connection
method signatures to follow DBAL v3 changes:
namespace Facile\DoctrineMySQLComeBack\Doctrine\DBAL;
use Doctrine\DBAL\Cache\QueryCacheProfile;
use Doctrine\DBAL\Connection as DBALConnection;
+use Doctrine\DBAL\Result;
class Connection extends DBALConnection
{
// ...
- public function prepare($sql)
+ public function prepare(string $sql): DBALStatement
// ...
- public function executeQuery($query, array $params = array(), $types = array(), QueryCacheProfile $qcp = null)
+ public function executeQuery(string $sql, array $params = [], $types = [], ?QueryCacheProfile $qcp = null): Result
// ...
}
- Change
Statement
constructor and method signatures to follow DBAL v3 changes:
namespace Facile\DoctrineMySQLComeBack\Doctrine\DBAL;
use Doctrine\DBAL\Cache\QueryCacheProfile;
use Doctrine\DBAL\Connection as DBALConnection;
+use Doctrine\DBAL\Result;
class Statement extends \Doctrine\DBAL\Statement
{
// ...
- public function __construct($sql, ConnectionInterface $conn)
+ public function __construct(Connection $retriableConnection, Driver\Statement $statement, string $sql)
// ...
- public function executeQuery($query, array $params = array(), $types = array(), QueryCacheProfile $qcp = null)
+ public function executeQuery(string $sql, array $params = [], $types = [], ?QueryCacheProfile $qcp = null): Result
// ...
}
Fixed
- In
PrimaryReadReplicaConnection
, fetchdriverOptions
from under theprimary
key
Removed
- Drop support for DBAL v2
- Drop support for PHP 7.3
- Removed
Facile\DoctrineMySQLComeBack\Doctrine\DBAL\Connections\MasterSlaveConnection
class - Removed
Facile\DoctrineMySQLComeBack\Doctrine\DBAL\Driver\ServerGoneAwayExceptionsAwareInterface
interface - Removed
Facile\DoctrineMySQLComeBack\Doctrine\DBAL\Driver\ServerGoneAwayExceptionsAwareTrait
trait - Removed
Facile\DoctrineMySQLComeBack\Doctrine\DBAL\Driver\Mysqli\Driver
class - Removed
Facile\DoctrineMySQLComeBack\Doctrine\DBAL\Driver\PDOMySQL\Driver
class - Removed
Facile\DoctrineMySQLComeBack\Doctrine\DBAL\Driver\PDO\MySQL\Driver
class - Removed
Connection::query()
method (due to drop in DBAL v3) - Removed
Connection::refresh()
method (due to drop in DBAL v3) - Removed
Connection::isUpdateQuery()
method (logic is now behind theGoneAwayDetector
interface) - Removed
Statement::bindValue()
method - Removed
Statement::bindParam()
method - Removed
Statement::execute()
method - Removed
Statement::setFetchMode()
method