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

Backport removal of deprecated APIs from develop #4082

Merged
merged 21 commits into from
Jun 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
6ed32a9
Remove deprecated json_array type
Majkl578 Apr 15, 2019
d293298
Remove deprecated Connection::TRANSACTION_* constants
Majkl578 Apr 15, 2019
f3828fb
Remove deprecated AbstractPlatform::DATE_INTERVAL_UNIT_* and Abstract…
Majkl578 Apr 15, 2019
a2f1af7
Remove deprecated MysqlSessionInit listener
Majkl578 Apr 15, 2019
6b65137
Remove deprecated MysqlPlatform::getCollationFieldDeclaration()
Majkl578 Apr 15, 2019
3d5847a
Remove deprecated AbstractPlatform::getIdentityColumnNullInsertSQL()
Majkl578 Apr 15, 2019
904d675
Remove deprecated Table::addUnnamedForeignKeyConstraint() and Table::…
Majkl578 Apr 15, 2019
21160fb
SQLParserUtils::*_TOKEN constants made private
Majkl578 Apr 15, 2019
388ea62
Remove deprecated SQLParserUtils::getPlaceholderPositions()
Majkl578 Apr 15, 2019
318c15b
Remove deprecated Table::renameColumn()
Majkl578 Apr 15, 2019
5e7ceff
Remove deprecated AbstractSchemaManager::getFilterSchemaAssetsExpress…
Majkl578 Apr 15, 2019
36bb4e5
Removed Driver::getName()
morozov May 23, 2019
460f0a1
Removed Driver::getDatabase() in favor of Connection::getDatabase()
morozov Jun 4, 2019
39a7a77
Removed some unused code bits
morozov Jun 6, 2019
c58dd2f
Remove deprecated methods from event-related classes
morozov May 30, 2019
138eb85
Remove deprecated stuff for 3.0
jwage May 31, 2019
13bef8a
Remove deprecated Connection methods
morozov Jun 17, 2020
a567da8
Removed support for DB-generated UUIDs
morozov Jul 11, 2018
23e8d5d
Remove deprecated SchemaManager methods
jwage May 28, 2019
06dc97e
Remove LoggerChain::addLogger
ostrolucky Jun 1, 2019
6a7f690
Remove Doctrine\DBAL\Types\Type::__toString()
Majkl578 Aug 17, 2018
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
51 changes: 51 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,56 @@
# Upgrade to 3.0

## BC BREAK: `Doctrine\DBAL\Types\Type::__toString()` removed

Relying on string representation was discouraged and has been removed.

## BC BREAK: Changes in the `Doctrine\DBAL\Schema` API

- Removed unused method `Doctrine\DBAL\Schema\AbstractSchemaManager::_getPortableFunctionsList()`
- Removed unused method `Doctrine\DBAL\Schema\AbstractSchemaManager::_getPortableFunctionDefinition()`
- Removed unused method `Doctrine\DBAL\Schema\OracleSchemaManager::_getPortableFunctionDefinition()`
- Removed unused method `Doctrine\DBAL\Schema\SqliteSchemaManager::_getPortableTableIndexDefinition()`

## BC BREAK: Removed support for DB-generated UUIDs

The support for DB-generated UUIDs was removed as non-portable.
Please generate UUIDs on the application side (e.g. using [ramsey/uuid](https://packagist.org/packages/ramsey/uuid)).

## BC BREAK: Changes in the `Doctrine\DBAL\Connection` API

- The following methods have been removed as leaking internal implementation details: `::getHost()`, `::getPort()`, `::getUsername()`, `::getPassword()`.

## BC BREAK: Changes in the `Doctrine\DBAL\Event` API

- `ConnectionEventArgs::getDriver()`, `::getDatabasePlatform()` and `::getSchemaManager()` methods have been removed. The connection information can be obtained from the connection which is available via `::getConnection()`.
- `SchemaColumnDefinitionEventArgs::getDatabasePlatform()` and `SchemaIndexDefinitionEventArgs::getDatabasePlatform()` have been removed for the same reason as above.

## BC BREAK: Changes in obtaining the currently selected database name

- The `Doctrine\DBAL\Driver::getDatabase()` method has been removed. Please use `Doctrine\DBAL\Connection::getDatabase()` instead.
- `Doctrine\DBAL\Connection::getDatabase()` will always return the name of the database currently connected to, regardless of the configuration parameters and will initialize a database connection if it's not yet established.
- A call to `Doctrine\DBAL\Connection::getDatabase()`, when connected to an SQLite database, will no longer return the database file path.

## BC BREAK: `Doctrine\DBAL\Driver::getName()` removed

The `Doctrine\DBAL\Driver::getName()` has been removed.

## BC BREAK Removed previously deprecated features

* Removed `json_array` type and all associated hacks.
* Removed `Connection::TRANSACTION_*` constants.
* Removed `AbstractPlatform::DATE_INTERVAL_UNIT_*` and `AbstractPlatform::TRIM_*` constants.
* Removed `MysqlSessionInit` listener.
* Removed `MysqlPlatform::getCollationFieldDeclaration()`.
* Removed `AbstractPlatform::getIdentityColumnNullInsertSQL()`.
* Removed `Table::addUnnamedForeignKeyConstraint()` and `Table::addNamedForeignKeyConstraint()`.
* Removed `Table::renameColumn()`.
* Removed `SQLParserUtils::getPlaceholderPositions()`.
* Removed `LoggerChain::addLogger`.
* Removed `AbstractSchemaManager::getFilterSchemaAssetsExpression()`, `Configuration::getFilterSchemaAssetsExpression()`
and `Configuration::getFilterSchemaAssetsExpression()`.
* `SQLParserUtils::*_TOKEN` constants made private.

## BC BREAK changes the `Driver::connect()` signature

The method no longer accepts the `$username`, `$password` and `$driverOptions` arguments. The corresponding values are expected to be passed as the "user", "password" and "driver_options" keys of the `$params` argument respectively.
Expand Down
52 changes: 0 additions & 52 deletions src/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@

use Doctrine\Common\Cache\Cache;
use Doctrine\DBAL\Logging\SQLLogger;
use Doctrine\DBAL\Schema\AbstractAsset;

use function preg_match;

/**
* Configuration container for the Doctrine DBAL.
Expand Down Expand Up @@ -64,55 +61,6 @@ public function setResultCacheImpl(Cache $cacheImpl)
$this->_attributes['resultCacheImpl'] = $cacheImpl;
}

/**
* Sets the filter schema assets expression.
*
* Only include tables/sequences matching the filter expression regexp in
* schema instances generated for the active connection when calling
* {AbstractSchemaManager#createSchema()}.
*
* @deprecated Use Configuration::setSchemaAssetsFilter() instead
*
* @param string|null $filterExpression
*
* @return void
*/
public function setFilterSchemaAssetsExpression($filterExpression)
{
$this->_attributes['filterSchemaAssetsExpression'] = $filterExpression;
if ($filterExpression !== null) {
$this->_attributes['filterSchemaAssetsExpressionCallable'] = $this->buildSchemaAssetsFilterFromExpression($filterExpression);
} else {
$this->_attributes['filterSchemaAssetsExpressionCallable'] = null;
}
}

/**
* Returns filter schema assets expression.
*
* @deprecated Use Configuration::getSchemaAssetsFilter() instead
*
* @return string|null
*/
public function getFilterSchemaAssetsExpression()
{
return $this->_attributes['filterSchemaAssetsExpression'] ?? null;
}

/**
* @param string $filterExpression
*/
private function buildSchemaAssetsFilterFromExpression($filterExpression): callable
{
return static function ($assetName) use ($filterExpression) {
if ($assetName instanceof AbstractAsset) {
$assetName = $assetName->getName();
}

return preg_match($filterExpression, $assetName);
};
}

/**
* Sets the callable to use to filter schema assets.
*/
Expand Down
88 changes: 11 additions & 77 deletions src/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,34 +40,6 @@
*/
class Connection implements DriverConnection
{
/**
* Constant for transaction isolation level READ UNCOMMITTED.
*
* @deprecated Use TransactionIsolationLevel::READ_UNCOMMITTED.
*/
public const TRANSACTION_READ_UNCOMMITTED = TransactionIsolationLevel::READ_UNCOMMITTED;

/**
* Constant for transaction isolation level READ COMMITTED.
*
* @deprecated Use TransactionIsolationLevel::READ_COMMITTED.
*/
public const TRANSACTION_READ_COMMITTED = TransactionIsolationLevel::READ_COMMITTED;

/**
* Constant for transaction isolation level REPEATABLE READ.
*
* @deprecated Use TransactionIsolationLevel::REPEATABLE_READ.
*/
public const TRANSACTION_REPEATABLE_READ = TransactionIsolationLevel::REPEATABLE_READ;

/**
* Constant for transaction isolation level SERIALIZABLE.
*
* @deprecated Use TransactionIsolationLevel::SERIALIZABLE.
*/
public const TRANSACTION_SERIALIZABLE = TransactionIsolationLevel::SERIALIZABLE;

/**
* Represents an array of ints to be expanded by Doctrine SQL parsing.
*/
Expand Down Expand Up @@ -225,61 +197,23 @@ public function getParams()
}

/**
* Gets the name of the database this Connection is connected to.
*
* @return string
*/
public function getDatabase()
{
return $this->_driver->getDatabase($this);
}

/**
* Gets the hostname of the currently connected database.
*
* @deprecated
*
* @return string|null
*/
public function getHost()
{
return $this->params['host'] ?? null;
}

/**
* Gets the port of the currently connected database.
* Gets the name of the currently selected database.
*
* @deprecated
* @return string|null The name of the database or NULL if a database is not selected.
* The platforms which don't support the concept of a database (e.g. embedded databases)
* must always return a string as an indicator of an implicitly selected database.
*
* @return mixed
* @throws DBALException
*/
public function getPort()
public function getDatabase()
{
return $this->params['port'] ?? null;
}
$platform = $this->getDatabasePlatform();
$query = $platform->getDummySelectSQL($platform->getCurrentDatabaseExpression());
$database = $this->query($query)->fetchOne();

/**
* Gets the username used by this connection.
*
* @deprecated
*
* @return string|null
*/
public function getUsername()
{
return $this->params['user'] ?? null;
}
assert(is_string($database) || $database === null);

/**
* Gets the password used by this connection.
*
* @deprecated
*
* @return string|null
*/
public function getPassword()
{
return $this->params['password'] ?? null;
return $database;
}

/**
Expand Down
18 changes: 0 additions & 18 deletions src/Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,4 @@ public function getDatabasePlatform();
* @return AbstractSchemaManager
*/
public function getSchemaManager(Connection $conn);

/**
* Gets the name of the driver.
*
* @deprecated
*
* @return string The name of the driver.
*/
public function getName();

/**
* Gets the name of the database connected to for this driver.
*
* @deprecated Use Connection::getDatabase() instead.
*
* @return string The name of the database.
*/
public function getDatabase(Connection $conn);
}
12 changes: 0 additions & 12 deletions src/Driver/AbstractDB2Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,6 @@
*/
abstract class AbstractDB2Driver implements Driver
{
/**
* {@inheritdoc}
*
* @deprecated Use Connection::getDatabase() instead.
*/
public function getDatabase(Connection $conn)
{
$params = $conn->getParams();

return $params['dbname'];
}

/**
* {@inheritdoc}
*/
Expand Down
12 changes: 0 additions & 12 deletions src/Driver/AbstractMySQLDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,18 +194,6 @@ private function getMariaDbMysqlVersionNumber(string $versionString): string
return $versionParts['major'] . '.' . $versionParts['minor'] . '.' . $versionParts['patch'];
}

/**
* {@inheritdoc}
*
* @deprecated Use Connection::getDatabase() instead.
*/
public function getDatabase(Connection $conn)
{
$params = $conn->getParams();

return $params['dbname'] ?? $conn->query('SELECT DATABASE()')->fetchOne();
}

/**
* {@inheritdoc}
*
Expand Down
12 changes: 0 additions & 12 deletions src/Driver/AbstractOracleDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,6 @@ public function convertException($message, DriverException $exception)
return new Exception\DriverException($message, $exception);
}

/**
* {@inheritdoc}
*
* @deprecated Use Connection::getDatabase() instead.
*/
public function getDatabase(Connection $conn)
{
$params = $conn->getParams();

return $params['user'];
}

/**
* {@inheritdoc}
*/
Expand Down
12 changes: 0 additions & 12 deletions src/Driver/AbstractPostgreSQLDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,18 +102,6 @@ public function createDatabasePlatformForVersion($version)
return new PostgreSQL94Platform();
}

/**
* {@inheritdoc}
*
* @deprecated Use Connection::getDatabase() instead.
*/
public function getDatabase(Connection $conn)
{
$params = $conn->getParams();

return $params['dbname'] ?? $conn->query('SELECT CURRENT_DATABASE()')->fetchOne();
}

/**
* {@inheritdoc}
*/
Expand Down
12 changes: 0 additions & 12 deletions src/Driver/AbstractSQLServerDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,6 @@
*/
abstract class AbstractSQLServerDriver implements Driver
{
/**
* {@inheritdoc}
*
* @deprecated Use Connection::getDatabase() instead.
*/
public function getDatabase(Connection $conn)
{
$params = $conn->getParams();

return $params['dbname'] ?? $conn->query('SELECT DB_NAME()')->fetchOne();
}

/**
* {@inheritdoc}
*/
Expand Down
12 changes: 0 additions & 12 deletions src/Driver/AbstractSQLiteDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,6 @@ public function convertException($message, DriverException $exception)
return new Exception\DriverException($message, $exception);
}

/**
* {@inheritdoc}
*
* @deprecated Use Connection::getDatabase() instead.
*/
public function getDatabase(Connection $conn)
{
$params = $conn->getParams();

return $params['path'] ?? null;
}

/**
* {@inheritdoc}
*/
Expand Down
10 changes: 0 additions & 10 deletions src/Driver/IBMDB2/DB2Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,4 @@ public function connect(array $params)
$params['driver_options'] ?? []
);
}

/**
* {@inheritdoc}
*
* @deprecated
*/
public function getName()
{
return 'ibm_db2';
}
}
8 changes: 0 additions & 8 deletions src/Driver/Mysqli/Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,4 @@ private function withCharset(array $initializers, array $params): array

return $initializers;
}

/**
* {@inheritdoc}
*/
public function getName()
{
return 'mysqli';
}
}
Loading