Remove PingableConnection

parent 97fe49a7
# Upgrade to 3.0 # Upgrade to 3.0
## The `PingableConnection` interface is removed
The functionality of pinging the server is no longer supported.
## BC BREAK: Deprecated driver-level classes and interfaces are removed. ## BC BREAK: Deprecated driver-level classes and interfaces are removed.
- `AbstractDriverException` - `AbstractDriverException`
...@@ -169,9 +173,9 @@ The following classes have been removed: ...@@ -169,9 +173,9 @@ The following classes have been removed:
DBAL now requires MariaDB 10.1 or newer, support for unmaintained versions has been dropped. DBAL now requires MariaDB 10.1 or newer, support for unmaintained versions has been dropped.
If you are using any of the legacy versions, you have to upgrade to a newer MariaDB version (10.1+ is recommended). If you are using any of the legacy versions, you have to upgrade to a newer MariaDB version (10.1+ is recommended).
## BC BREAK: PingableConnection and ServerInfoAwareConnection interfaces now extend Connection ## BC BREAK: The ServerInfoAwareConnection interface now extend Connection
All implementations of the `PingableConnection` and `ServerInfoAwareConnection` interfaces have to implement the methods defined in the `Connection` interface as well. All implementations of the `ServerInfoAwareConnection` interface have to implement the methods defined in the `Connection` interface as well.
## BC BREAK: VersionAwarePlatformDriver interface now extends Driver ## BC BREAK: VersionAwarePlatformDriver interface now extends Driver
......
...@@ -11,7 +11,6 @@ use Doctrine\DBAL\Cache\CachingResult; ...@@ -11,7 +11,6 @@ use Doctrine\DBAL\Cache\CachingResult;
use Doctrine\DBAL\Cache\QueryCacheProfile; use Doctrine\DBAL\Cache\QueryCacheProfile;
use Doctrine\DBAL\Driver\Connection as DriverConnection; use Doctrine\DBAL\Driver\Connection as DriverConnection;
use Doctrine\DBAL\Driver\Exception as DriverException; use Doctrine\DBAL\Driver\Exception as DriverException;
use Doctrine\DBAL\Driver\PingableConnection;
use Doctrine\DBAL\Driver\Result as DriverResult; use Doctrine\DBAL\Driver\Result as DriverResult;
use Doctrine\DBAL\Driver\ServerInfoAwareConnection; use Doctrine\DBAL\Driver\ServerInfoAwareConnection;
use Doctrine\DBAL\Driver\Statement as DriverStatement; use Doctrine\DBAL\Driver\Statement as DriverStatement;
...@@ -1634,46 +1633,6 @@ class Connection implements DriverConnection ...@@ -1634,46 +1633,6 @@ class Connection implements DriverConnection
return new Query\QueryBuilder($this); return new Query\QueryBuilder($this);
} }
/**
* Ping the server
*
* When the server is not available the method returns FALSE.
* It is responsibility of the developer to handle this case
* and abort the request or reconnect manually:
*
* @deprecated
*
* @return bool
*
* @example
*
* if ($conn->ping() === false) {
* $conn->close();
* $conn->connect();
* }
*
* It is undefined if the underlying driver attempts to reconnect
* or disconnect when the connection is not available anymore
* as long it returns TRUE when a reconnect succeeded and
* FALSE when the connection was dropped.
*/
public function ping()
{
$connection = $this->getWrappedConnection();
if ($connection instanceof PingableConnection) {
return $connection->ping();
}
try {
$this->query($this->getDatabasePlatform()->getDummySelectSQL());
return true;
} catch (DBALException $e) {
return false;
}
}
/** /**
* @internal * @internal
* *
......
...@@ -5,7 +5,6 @@ namespace Doctrine\DBAL\Driver\Mysqli; ...@@ -5,7 +5,6 @@ namespace Doctrine\DBAL\Driver\Mysqli;
use Doctrine\DBAL\Driver\Exception; use Doctrine\DBAL\Driver\Exception;
use Doctrine\DBAL\Driver\Mysqli\Exception\ConnectionError; use Doctrine\DBAL\Driver\Mysqli\Exception\ConnectionError;
use Doctrine\DBAL\Driver\Mysqli\Exception\ConnectionFailed; use Doctrine\DBAL\Driver\Mysqli\Exception\ConnectionFailed;
use Doctrine\DBAL\Driver\PingableConnection;
use Doctrine\DBAL\Driver\Result as ResultInterface; use Doctrine\DBAL\Driver\Result as ResultInterface;
use Doctrine\DBAL\Driver\ServerInfoAwareConnection; use Doctrine\DBAL\Driver\ServerInfoAwareConnection;
use Doctrine\DBAL\Driver\Statement as DriverStatement; use Doctrine\DBAL\Driver\Statement as DriverStatement;
...@@ -16,7 +15,7 @@ use function floor; ...@@ -16,7 +15,7 @@ use function floor;
use function mysqli_init; use function mysqli_init;
use function stripos; use function stripos;
final class Connection implements PingableConnection, ServerInfoAwareConnection final class Connection implements ServerInfoAwareConnection
{ {
/** /**
* Name of the option to set connection flags * Name of the option to set connection flags
...@@ -154,16 +153,4 @@ final class Connection implements PingableConnection, ServerInfoAwareConnection ...@@ -154,16 +153,4 @@ final class Connection implements PingableConnection, ServerInfoAwareConnection
{ {
return $this->conn->rollback(); return $this->conn->rollback();
} }
/**
* Pings the server and re-connects when `mysqli.reconnect = 1`
*
* @deprecated
*
* @return bool
*/
public function ping()
{
return $this->conn->ping();
}
} }
<?php
namespace Doctrine\DBAL\Driver;
/**
* An interface for connections which support a "native" ping method.
*
* @deprecated
*/
interface PingableConnection extends Connection
{
/**
* Pings the database server to determine if the connection is still
* available. Return true/false based on if that was successful or not.
*
* @return bool
*/
public function ping();
}
...@@ -311,12 +311,6 @@ class ConnectionTest extends FunctionalTestCase ...@@ -311,12 +311,6 @@ class ConnectionTest extends FunctionalTestCase
); );
} }
public function testPingDoesTriggersConnect(): void
{
self::assertTrue($this->connection->ping());
self::assertTrue($this->connection->isConnected());
}
/** /**
* @group DBAL-1025 * @group DBAL-1025
*/ */
......
...@@ -61,12 +61,6 @@ class ConnectionTest extends FunctionalTestCase ...@@ -61,12 +61,6 @@ class ConnectionTest extends FunctionalTestCase
); );
} }
public function testPing(): void
{
$conn = $this->getConnection([]);
self::assertTrue($conn->ping());
}
/** /**
* @param mixed[] $driverOptions * @param mixed[] $driverOptions
*/ */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment