updated-packages

This commit is contained in:
RafficMohammed
2023-01-08 00:13:22 +05:30
parent 3ff7df7487
commit da241bacb6
12659 changed files with 563377 additions and 510538 deletions

View File

@@ -11,6 +11,7 @@ use Doctrine\DBAL\Event\ConnectionEventArgs;
use Doctrine\DBAL\Events;
use Doctrine\DBAL\Sharding\ShardChoser\ShardChoser;
use InvalidArgumentException;
use function array_merge;
use function is_numeric;
use function is_string;
@@ -26,12 +27,14 @@ use function is_string;
* - By default, the global shard is selected. If no global shard is configured
* an exception is thrown on access.
* - Selecting a shard by distribution value delegates the mapping
* "distributionValue" => "client" to the ShardChooser interface.
* "distributionValue" => "client" to the ShardChoser interface.
* - An exception is thrown if trying to switch shards during an open
* transaction.
*
* Instantiation through the DriverManager looks like:
*
* @deprecated
*
* @example
*
* $conn = DriverManager::getConnection(array(
@@ -53,7 +56,7 @@ class PoolingShardConnection extends Connection
/** @var DriverConnection[] */
private $activeConnections = [];
/** @var int|null */
/** @var string|int|null */
private $activeShardId;
/** @var mixed[] */
@@ -62,10 +65,16 @@ class PoolingShardConnection extends Connection
/**
* {@inheritDoc}
*
* @internal The connection can be only instantiated by the driver manager.
*
* @throws InvalidArgumentException
*/
public function __construct(array $params, Driver $driver, ?Configuration $config = null, ?EventManager $eventManager = null)
{
public function __construct(
array $params,
Driver $driver,
?Configuration $config = null,
?EventManager $eventManager = null
) {
if (! isset($params['global'], $params['shards'])) {
throw new InvalidArgumentException("Connection Parameters require 'global' and 'shards' configurations.");
}
@@ -79,14 +88,18 @@ class PoolingShardConnection extends Connection
}
if (! ($params['shardChoser'] instanceof ShardChoser)) {
throw new InvalidArgumentException("The 'shardChoser' configuration is not a valid instance of Doctrine\DBAL\Sharding\ShardChoser\ShardChoser");
throw new InvalidArgumentException(
"The 'shardChoser' configuration is not a valid instance of " . ShardChoser::class
);
}
$this->connectionParameters[0] = array_merge($params, $params['global']);
foreach ($params['shards'] as $shard) {
if (! isset($shard['id'])) {
throw new InvalidArgumentException("Missing 'id' for one configured shard. Please specify a unique shard-id.");
throw new InvalidArgumentException(
"Missing 'id' for one configured shard. Please specify a unique shard-id."
);
}
if (! is_numeric($shard['id']) || $shard['id'] < 1) {
@@ -106,7 +119,7 @@ class PoolingShardConnection extends Connection
/**
* Get active shard id.
*
* @return int
* @return string|int|null
*/
public function getActiveShardId()
{
@@ -118,7 +131,9 @@ class PoolingShardConnection extends Connection
*/
public function getParams()
{
return $this->activeShardId ? $this->connectionParameters[$this->activeShardId] : $this->connectionParameters[0];
return $this->activeShardId
? $this->connectionParameters[$this->activeShardId]
: $this->connectionParameters[0];
}
/**
@@ -164,7 +179,7 @@ class PoolingShardConnection extends Connection
/**
* Connects to a given shard.
*
* @param mixed $shardId
* @param string|int|null $shardId
*
* @return bool
*
@@ -184,15 +199,15 @@ class PoolingShardConnection extends Connection
throw new ShardingException('Cannot switch shard when transaction is active.');
}
$this->activeShardId = (int) $shardId;
$activeShardId = $this->activeShardId = (int) $shardId;
if (isset($this->activeConnections[$this->activeShardId])) {
$this->_conn = $this->activeConnections[$this->activeShardId];
if (isset($this->activeConnections[$activeShardId])) {
$this->_conn = $this->activeConnections[$activeShardId];
return false;
}
$this->_conn = $this->activeConnections[$this->activeShardId] = $this->connectTo($this->activeShardId);
$this->_conn = $this->activeConnections[$activeShardId] = $this->connectTo($activeShardId);
if ($this->_eventManager->hasListeners(Events::postConnect)) {
$eventArgs = new ConnectionEventArgs($this);
@@ -205,7 +220,7 @@ class PoolingShardConnection extends Connection
/**
* Connects to a specific connection.
*
* @param string $shardId
* @param string|int $shardId
*
* @return \Doctrine\DBAL\Driver\Connection
*/
@@ -224,7 +239,7 @@ class PoolingShardConnection extends Connection
}
/**
* @param string|null $shardId
* @param string|int|null $shardId
*
* @return bool
*/

View File

@@ -3,10 +3,13 @@
namespace Doctrine\DBAL\Sharding;
use Doctrine\DBAL\Sharding\ShardChoser\ShardChoser;
use Doctrine\Deprecations\Deprecation;
use RuntimeException;
/**
* Shard Manager for the Connection Pooling Shard Strategy
*
* @deprecated
*/
class PoolingShardManager implements ShardManager
{
@@ -21,6 +24,12 @@ class PoolingShardManager implements ShardManager
public function __construct(PoolingShardConnection $conn)
{
Deprecation::trigger(
'doctrine/dbal',
'https://github.com/doctrine/dbal/issues/3595',
'Native Sharding support in DBAL is removed without replacement.'
);
$params = $conn->getParams();
$this->conn = $conn;
$this->choser = $params['shardChoser'];
@@ -85,7 +94,7 @@ class PoolingShardManager implements ShardManager
foreach ($shards as $shard) {
$this->conn->connect($shard['id']);
foreach ($this->conn->fetchAll($sql, $params, $types) as $row) {
foreach ($this->conn->fetchAllAssociative($sql, $params, $types) as $row) {
$result[] = $row;
}
}

View File

@@ -9,7 +9,9 @@ use Doctrine\DBAL\Schema\Synchronizer\AbstractSchemaSynchronizer;
use Doctrine\DBAL\Schema\Synchronizer\SchemaSynchronizer;
use Doctrine\DBAL\Schema\Synchronizer\SingleDatabaseSynchronizer;
use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Types\Types;
use RuntimeException;
use function array_merge;
/**
@@ -19,6 +21,8 @@ use function array_merge;
* by partitioning the passed schema into subschemas for the federation and the
* global database and then applying the operations step by step using the
* {@see \Doctrine\DBAL\Schema\Synchronizer\SingleDatabaseSynchronizer}.
*
* @deprecated
*/
class SQLAzureFederationsSynchronizer extends AbstractSchemaSynchronizer
{
@@ -60,7 +64,9 @@ class SQLAzureFederationsSynchronizer extends AbstractSchemaSynchronizer
$defaultValue = $this->getFederationTypeDefaultValue();
$sql[] = $this->getCreateFederationStatement();
$sql[] = 'USE FEDERATION ' . $this->shardManager->getFederationName() . ' (' . $this->shardManager->getDistributionKey() . ' = ' . $defaultValue . ') WITH RESET, FILTERING = OFF;';
$sql[] = 'USE FEDERATION ' . $this->shardManager->getFederationName()
. ' (' . $this->shardManager->getDistributionKey() . ' = ' . $defaultValue . ')'
. ' WITH RESET, FILTERING = OFF;';
$sql = array_merge($sql, $federationSql);
}
@@ -119,6 +125,8 @@ class SQLAzureFederationsSynchronizer extends AbstractSchemaSynchronizer
$this->shardManager->selectGlobal();
$globalSql = $this->synchronizer->getDropAllSchema();
$sql = [];
if ($globalSql) {
$sql[] = "-- Work on Root Federation\nUSE FEDERATION ROOT WITH RESET;";
$sql = array_merge($sql, $globalSql);
@@ -134,7 +142,9 @@ class SQLAzureFederationsSynchronizer extends AbstractSchemaSynchronizer
}
$sql[] = '-- Work on Federation ID ' . $shard['id'] . "\n" .
'USE FEDERATION ' . $this->shardManager->getFederationName() . ' (' . $this->shardManager->getDistributionKey() . ' = ' . $shard['rangeLow'] . ') WITH RESET, FILTERING = OFF;';
'USE FEDERATION ' . $this->shardManager->getFederationName()
. ' (' . $this->shardManager->getDistributionKey() . ' = ' . $shard['rangeLow'] . ')'
. ' WITH RESET, FILTERING = OFF;';
$sql = array_merge($sql, $federationSql);
}
@@ -224,8 +234,10 @@ class SQLAzureFederationsSynchronizer extends AbstractSchemaSynchronizer
continue;
}
$sql[] = '-- Work on Federation ID ' . $shard['id'] . "\n" .
'USE FEDERATION ' . $this->shardManager->getFederationName() . ' (' . $this->shardManager->getDistributionKey() . ' = ' . $shard['rangeLow'] . ') WITH RESET, FILTERING = OFF;';
$sql[] = '-- Work on Federation ID ' . $shard['id'] . "\n"
. 'USE FEDERATION ' . $this->shardManager->getFederationName()
. ' (' . $this->shardManager->getDistributionKey() . ' = ' . $shard['rangeLow'] . ')'
. ' WITH RESET, FILTERING = OFF;';
$sql = array_merge($sql, $federationSql);
}
@@ -240,12 +252,12 @@ class SQLAzureFederationsSynchronizer extends AbstractSchemaSynchronizer
$federationType = Type::getType($this->shardManager->getDistributionType());
switch ($federationType->getName()) {
case Type::GUID:
case Types::GUID:
$defaultValue = '00000000-0000-0000-0000-000000000000';
break;
case Type::INTEGER:
case Type::SMALLINT:
case Type::BIGINT:
case Types::INTEGER:
case Types::SMALLINT:
case Types::BIGINT:
$defaultValue = '0';
break;
default:
@@ -264,7 +276,9 @@ class SQLAzureFederationsSynchronizer extends AbstractSchemaSynchronizer
$federationType = Type::getType($this->shardManager->getDistributionType());
$federationTypeSql = $federationType->getSQLDeclaration([], $this->conn->getDatabasePlatform());
return "--Create Federation\n" .
'CREATE FEDERATION ' . $this->shardManager->getFederationName() . ' (' . $this->shardManager->getDistributionKey() . ' ' . $federationTypeSql . ' RANGE)';
return "--Create Federation\n"
. 'CREATE FEDERATION ' . $this->shardManager->getFederationName()
. ' (' . $this->shardManager->getDistributionKey()
. ' ' . $federationTypeSql . ' RANGE)';
}
}

View File

@@ -6,13 +6,15 @@ use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Sharding\ShardingException;
use Doctrine\DBAL\Sharding\ShardManager;
use Doctrine\DBAL\Types\Type;
use Doctrine\Deprecations\Deprecation;
use RuntimeException;
use function is_bool;
use function is_scalar;
use function sprintf;
/**
* Sharding using the SQL Azure Federations support.
*
* @deprecated
*/
class SQLAzureShardManager implements ShardManager
{
@@ -39,6 +41,12 @@ class SQLAzureShardManager implements ShardManager
*/
public function __construct(Connection $conn)
{
Deprecation::trigger(
'doctrine/dbal',
'https://github.com/doctrine/dbal/issues/3595',
'Native Sharding support in DBAL is removed without replacement.'
);
$this->conn = $conn;
$params = $conn->getParams();
@@ -125,10 +133,6 @@ class SQLAzureShardManager implements ShardManager
throw ShardingException::activeTransaction();
}
if ($distributionValue === null || is_bool($distributionValue) || ! is_scalar($distributionValue)) {
throw ShardingException::noShardDistributionValue();
}
$platform = $this->conn->getDatabasePlatform();
$sql = sprintf(
'USE FEDERATION %s (%s = %s) WITH RESET, FILTERING = %s;',
@@ -163,7 +167,7 @@ class SQLAzureShardManager implements ShardManager
INNER JOIN sys.federations f ON f.federation_id = d.federation_id
WHERE f.name = ' . $this->conn->quote($this->federationName);
return $this->conn->fetchAll($sql);
return $this->conn->fetchAllAssociative($sql);
}
/**
@@ -181,7 +185,7 @@ class SQLAzureShardManager implements ShardManager
foreach ($shards as $shard) {
$this->selectShard($shard['rangeLow']);
foreach ($this->conn->fetchAll($sql, $params, $types) as $row) {
foreach ($this->conn->fetchAllAssociative($sql, $params, $types) as $row) {
$result[] = $row;
}
}

View File

@@ -10,6 +10,7 @@ use Doctrine\DBAL\Schema\Sequence;
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Schema\Visitor\Visitor;
use RuntimeException;
use function in_array;
/**
@@ -30,6 +31,8 @@ use function in_array;
* (otherwise they will affect the same-id rows from other tenants as well).
* SQLAzure throws errors when you try to create IDENTIY columns on federated
* tables.
*
* @deprecated
*/
class MultiTenantVisitor implements Visitor
{
@@ -108,6 +111,7 @@ class MultiTenantVisitor implements Visitor
return $index;
}
}
throw new RuntimeException('No clustered index found on table ' . $table->getName());
}

View File

@@ -7,6 +7,8 @@ use Doctrine\DBAL\Sharding\PoolingShardConnection;
/**
* The MultiTenant Shard choser assumes that the distribution value directly
* maps to the shard id.
*
* @deprecated
*/
class MultiTenantShardChoser implements ShardChoser
{

View File

@@ -7,6 +7,8 @@ use Doctrine\DBAL\Sharding\PoolingShardConnection;
/**
* Given a distribution value this shard-choser strategy will pick the shard to
* connect to for retrieving rows with the distribution value.
*
* @deprecated
*/
interface ShardChoser
{

View File

@@ -17,6 +17,8 @@ namespace Doctrine\DBAL\Sharding;
* executed against the last shard that was selected. If a query is created for
* a shard Y but then a shard X is selected when its actually executed you
* will hit the wrong shard.
*
* @deprecated
*/
interface ShardManager
{
@@ -62,7 +64,7 @@ interface ShardManager
* Queries all shards in undefined order and return the results appended to
* each other. Restore the previous distribution value after execution.
*
* Using {@link \Doctrine\DBAL\Connection::fetchAll} to retrieve rows internally.
* Using {@link Connection::fetchAll()} to retrieve rows internally.
*
* @param string $sql
* @param mixed[] $params

View File

@@ -2,15 +2,19 @@
namespace Doctrine\DBAL\Sharding;
use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Exception;
/**
* Sharding related Exceptions
*
* @deprecated
*
* @psalm-immutable
*/
class ShardingException extends DBALException
class ShardingException extends Exception
{
/**
* @return \Doctrine\DBAL\Sharding\ShardingException
* @return ShardingException
*/
public static function notImplemented()
{
@@ -18,7 +22,7 @@ class ShardingException extends DBALException
}
/**
* @return \Doctrine\DBAL\Sharding\ShardingException
* @return ShardingException
*/
public static function missingDefaultFederationName()
{
@@ -26,7 +30,7 @@ class ShardingException extends DBALException
}
/**
* @return \Doctrine\DBAL\Sharding\ShardingException
* @return ShardingException
*/
public static function missingDefaultDistributionKey()
{
@@ -34,7 +38,7 @@ class ShardingException extends DBALException
}
/**
* @return \Doctrine\DBAL\Sharding\ShardingException
* @return ShardingException
*/
public static function activeTransaction()
{
@@ -42,7 +46,7 @@ class ShardingException extends DBALException
}
/**
* @return \Doctrine\DBAL\Sharding\ShardingException
* @return ShardingException
*/
public static function noShardDistributionValue()
{
@@ -50,7 +54,7 @@ class ShardingException extends DBALException
}
/**
* @return \Doctrine\DBAL\Sharding\ShardingException
* @return ShardingException
*/
public static function missingDistributionType()
{