框架升级及修复升级后的bug

This commit is contained in:
Dev
2026-10-16 18:13:09 +08:00
parent dafb0c96c0
commit 2d342bcbd7
537 changed files with 49836 additions and 40933 deletions
+21 -12
View File
@@ -21,7 +21,6 @@ use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\Platforms\AbstractMySQLPlatform;
use Doctrine\DBAL\Platforms\OraclePlatform;
use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
use Doctrine\DBAL\Platforms\SQLitePlatform;
use Doctrine\DBAL\Platforms\SQLServerPlatform;
use Doctrine\DBAL\Schema\Column;
use Doctrine\DBAL\Schema\DefaultSchemaManagerFactory;
@@ -74,10 +73,6 @@ class DoctrineDbalAdapter extends AbstractAdapter implements PruneableInterface
array $options = [],
?MarshallerInterface $marshaller = null,
) {
if (!class_exists(PrimaryKeyConstraint::class)) {
throw new \LogicException(\sprintf('Using "%s" requires "doctrine/dbal" 4.3 or higher; try running "composer require doctrine/dbal:^4.3".', __CLASS__));
}
if (isset($namespace[0]) && preg_match('#[^-+.A-Za-z0-9]#', $namespace, $match)) {
throw new InvalidArgumentException(\sprintf('Namespace contains "%s" but only characters in [-+.A-Za-z0-9] are allowed.', $match[0]));
}
@@ -135,9 +130,9 @@ class DoctrineDbalAdapter extends AbstractAdapter implements PruneableInterface
}
/**
* @param-immediately-invoked-callable $isSameDatabase
* @return Schema The (possibly new) schema with the table added
*/
public function configureSchema(Schema $schema, Connection $forConnection, \Closure $isSameDatabase): Schema
public function configureSchema(Schema $schema, Connection $forConnection, \Closure $isSameDatabase)
{
if ($schema->hasTable($this->table)) {
return $schema;
@@ -222,13 +217,16 @@ class DoctrineDbalAdapter extends AbstractAdapter implements PruneableInterface
{
if ('' === $namespace) {
$sql = $this->conn->getDatabasePlatform()->getTruncateTableSQL($this->table);
$params = [];
} else {
$namespace = str_replace('_', '!_', $namespace);
$sql = "DELETE FROM $this->table WHERE $this->idCol LIKE '$namespace%' ESCAPE '!'";
// SQL Server also treats [ as a wildcard, while Oracle rejects an escape character followed by it
$namespace = preg_replace('sqlsrv' === $this->getPlatformName() ? '/[!%_[]/' : '/[!%_]/', '!$0', $namespace);
$sql = "DELETE FROM $this->table WHERE $this->idCol LIKE ? ESCAPE '!'";
$params = [$namespace.'%'];
}
try {
$this->conn->executeStatement($sql);
$this->conn->executeStatement($sql, $params);
} catch (TableNotFoundException) {
}
@@ -395,9 +393,16 @@ class DoctrineDbalAdapter extends AbstractAdapter implements PruneableInterface
$platform = $this->conn->getDatabasePlatform();
if (interface_exists(DBALException::class)) {
// DBAL 4+
$sqlitePlatformClass = 'Doctrine\DBAL\Platforms\SQLitePlatform';
} else {
$sqlitePlatformClass = 'Doctrine\DBAL\Platforms\SqlitePlatform';
}
return $this->platformName = match (true) {
$platform instanceof AbstractMySQLPlatform => 'mysql',
$platform instanceof SQLitePlatform => 'sqlite',
$platform instanceof $sqlitePlatformClass => 'sqlite',
$platform instanceof PostgreSQLPlatform => 'pgsql',
$platform instanceof OraclePlatform => 'oci',
$platform instanceof SQLServerPlatform => 'sqlsrv',
@@ -448,6 +453,10 @@ class DoctrineDbalAdapter extends AbstractAdapter implements PruneableInterface
$table->addColumn($this->lifetimeCol, 'integer', ['unsigned' => true, 'notnull' => false]);
$table->addColumn($this->timeCol, 'integer', ['unsigned' => true]);
$table->addPrimaryKeyConstraint(new PrimaryKeyConstraint(null, [new UnqualifiedName(Identifier::unquoted($this->idCol))], true));
if (class_exists(PrimaryKeyConstraint::class)) {
$table->addPrimaryKeyConstraint(new PrimaryKeyConstraint(null, [new UnqualifiedName(Identifier::unquoted($this->idCol))], true));
} else {
$table->setPrimaryKey([$this->idCol]);
}
}
}