bug #37563 Fix DBAL deprecation (nicolas-grekas)
This PR was merged into the 3.4 branch.
Discussion
----------
Fix DBAL deprecation
| Q | A
| ------------- | ---
| Branch? | 3.4
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets | -
| License | MIT
| Doc PR | -
Follows https://github.com/doctrine/dbal/pull/4163
Commits
-------
4273aedfae
Fix DBAL deprecation
This commit is contained in:
commit
3ae61ec22c
@ -81,8 +81,12 @@ class DoctrineTokenProvider implements TokenProviderInterface
|
|||||||
$sql = 'DELETE FROM rememberme_token WHERE series=:series';
|
$sql = 'DELETE FROM rememberme_token WHERE series=:series';
|
||||||
$paramValues = ['series' => $series];
|
$paramValues = ['series' => $series];
|
||||||
$paramTypes = ['series' => \PDO::PARAM_STR];
|
$paramTypes = ['series' => \PDO::PARAM_STR];
|
||||||
|
if (method_exists($this->conn, 'executeStatement')) {
|
||||||
|
$this->conn->executeStatement($sql, $paramValues, $paramTypes);
|
||||||
|
} else {
|
||||||
$this->conn->executeUpdate($sql, $paramValues, $paramTypes);
|
$this->conn->executeUpdate($sql, $paramValues, $paramTypes);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
@ -101,7 +105,11 @@ class DoctrineTokenProvider implements TokenProviderInterface
|
|||||||
'lastUsed' => self::$useDeprecatedConstants ? Type::DATETIME : Types::DATETIME_MUTABLE,
|
'lastUsed' => self::$useDeprecatedConstants ? Type::DATETIME : Types::DATETIME_MUTABLE,
|
||||||
'series' => \PDO::PARAM_STR,
|
'series' => \PDO::PARAM_STR,
|
||||||
];
|
];
|
||||||
|
if (method_exists($this->conn, 'executeStatement')) {
|
||||||
|
$updated = $this->conn->executeStatement($sql, $paramValues, $paramTypes);
|
||||||
|
} else {
|
||||||
$updated = $this->conn->executeUpdate($sql, $paramValues, $paramTypes);
|
$updated = $this->conn->executeUpdate($sql, $paramValues, $paramTypes);
|
||||||
|
}
|
||||||
if ($updated < 1) {
|
if ($updated < 1) {
|
||||||
throw new TokenNotFoundException('No token found.');
|
throw new TokenNotFoundException('No token found.');
|
||||||
}
|
}
|
||||||
@ -129,6 +137,10 @@ class DoctrineTokenProvider implements TokenProviderInterface
|
|||||||
'value' => \PDO::PARAM_STR,
|
'value' => \PDO::PARAM_STR,
|
||||||
'lastUsed' => self::$useDeprecatedConstants ? Type::DATETIME : Types::DATETIME_MUTABLE,
|
'lastUsed' => self::$useDeprecatedConstants ? Type::DATETIME : Types::DATETIME_MUTABLE,
|
||||||
];
|
];
|
||||||
|
if (method_exists($this->conn, 'executeStatement')) {
|
||||||
|
$this->conn->executeStatement($sql, $paramValues, $paramTypes);
|
||||||
|
} else {
|
||||||
$this->conn->executeUpdate($sql, $paramValues, $paramTypes);
|
$this->conn->executeUpdate($sql, $paramValues, $paramTypes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
@ -72,7 +72,7 @@ class DoctrineTokenProviderTest extends TestCase
|
|||||||
'driver' => 'pdo_sqlite',
|
'driver' => 'pdo_sqlite',
|
||||||
'url' => 'sqlite:///:memory:',
|
'url' => 'sqlite:///:memory:',
|
||||||
]);
|
]);
|
||||||
$connection->executeUpdate(<<< 'SQL'
|
$connection->{method_exists($this->conn, 'executeStatement') ? 'executeStatement' : 'executeUpdate'}(<<< 'SQL'
|
||||||
CREATE TABLE rememberme_token (
|
CREATE TABLE rememberme_token (
|
||||||
series char(88) UNIQUE PRIMARY KEY NOT NULL,
|
series char(88) UNIQUE PRIMARY KEY NOT NULL,
|
||||||
value char(88) NOT NULL,
|
value char(88) NOT NULL,
|
||||||
|
@ -107,8 +107,12 @@ trait PdoTrait
|
|||||||
$table->setPrimaryKey([$this->idCol]);
|
$table->setPrimaryKey([$this->idCol]);
|
||||||
|
|
||||||
foreach ($schema->toSql($conn->getDatabasePlatform()) as $sql) {
|
foreach ($schema->toSql($conn->getDatabasePlatform()) as $sql) {
|
||||||
|
if (method_exists($conn, 'executeStatement')) {
|
||||||
|
$conn->executeStatement($sql);
|
||||||
|
} else {
|
||||||
$conn->exec($sql);
|
$conn->exec($sql);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -138,8 +142,12 @@ trait PdoTrait
|
|||||||
throw new \DomainException(sprintf('Creating the cache table is currently not implemented for PDO driver "%s".', $this->driver));
|
throw new \DomainException(sprintf('Creating the cache table is currently not implemented for PDO driver "%s".', $this->driver));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (method_exists($conn, 'executeStatement')) {
|
||||||
|
$conn->executeStatement($sql);
|
||||||
|
} else {
|
||||||
$conn->exec($sql);
|
$conn->exec($sql);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
@ -238,7 +246,11 @@ trait PdoTrait
|
|||||||
$sql = "DELETE FROM $this->table WHERE $this->idCol LIKE '$namespace%'";
|
$sql = "DELETE FROM $this->table WHERE $this->idCol LIKE '$namespace%'";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (method_exists($conn, 'executeStatement')) {
|
||||||
|
$conn->executeStatement($sql);
|
||||||
|
} else {
|
||||||
$conn->exec($sql);
|
$conn->exec($sql);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user