Skip to content

Commit

Permalink
[Task]: Prepare for DBAL v4, replace deprecated methods (#13619)
Browse files Browse the repository at this point in the history
* task: replace deprecated changeColumn with modifyColumn

* task: replace deprecated getSchemaManager with createSchemaManager

* task: replace deprecated createSchema with introspectSchema

* task: replace queryBuild::execute createSchema with executeQuery

* task: bump to 3.5 when introspectSchema was introduced to fixtests
  • Loading branch information
kingjia90 committed Nov 28, 2022
1 parent 6590b4a commit 631a520
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions bundles/AdminBundle/src/Controller/Admin/LogController.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,10 @@ public function showAction(Request $request, Connection $db): JsonResponse
$totalQb->setMaxResults(null)
->setFirstResult(0)
->select('COUNT(id) as count');
$total = $totalQb->execute()->fetch();
$total = $totalQb->executeQuery()->fetch();
$total = (int) $total['count'];

$stmt = $qb->execute();
$stmt = $qb->executeQuery();
$result = $stmt->fetchAllAssociative();

$logEntries = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ final class Version20201008101817 extends AbstractMigration
{
public function up(Schema $schema): void
{
if (array_key_exists('documents_editables', $this->connection->getSchemaManager()->listViews())) {
if (array_key_exists('documents_editables', $this->connection->createSchemaManager()->listViews())) {
$this->addSql('DROP VIEW IF EXISTS documents_editables;');
}

Expand Down
4 changes: 2 additions & 2 deletions bundles/CoreBundle/src/Migrations/Version20211018104331.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,15 @@ private function createForeignKey(Table $tableSchema, string $localForeignKeyCol
$column = $tableSchema->getColumn($localForeignKeyColumn);

if ($column->getPrecision() !== 10 || !($column->getType() instanceof IntegerType)) {
$tableSchema->changeColumn($localForeignKeyColumn, [
$tableSchema->modifyColumn($localForeignKeyColumn, [
'type' => new IntegerType(),
'precision' => 10,
'unsigned' => true,
]);
}

if (!$column->hasCustomSchemaOption('unsigned') || $column->getCustomSchemaOption('unsigned') === false) {
$tableSchema->changeColumn($localForeignKeyColumn, ['unsigned' => true]);
$tableSchema->modifyColumn($localForeignKeyColumn, ['unsigned' => true]);
}

$tableSchema->addForeignKeyConstraint('objects', [$localForeignKeyColumn], ['o_id'], ['onDelete' => 'CASCADE'], $fkName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ protected function fetchProductIdsForPreparationForSingleStoreTable(string $stor
{
$qb = $this->createBasicStoreTableSelectQuery($storeTableName, $tenantNameFilterList);
$qb->andWhere('in_preparation_queue = 1');
$rows = $qb->execute()->fetchAllAssociative();
$rows = $qb->executeQuery()->fetchAllAssociative();

$result = [];

Expand Down Expand Up @@ -129,7 +129,7 @@ protected function fetchProductIdsIndexUpdateForSingleStoreTable(string $storeTa
{
$qb = $this->createBasicStoreTableSelectQuery($storeTableName, $tenantNameFilterList);
$qb->andWhere('crc_current != crc_index OR ISNULL(crc_index)');
$rows = $qb->execute()->fetchAllAssociative();
$rows = $qb->executeQuery()->fetchAllAssociative();

$result = [];
foreach ($rows as $row) {
Expand Down Expand Up @@ -218,7 +218,7 @@ protected function resetIds(array $idList, string $triggerInfo, bool $onlyResetU
$ids = implode(',', $idList);
$qb->where(sprintf('o_id in (%s)', $ids));

$qb->execute();
$qb->executeQuery();
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion bundles/EcommerceFrameworkBundle/src/Tools/Installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,6 @@ public function needsReloadAfterInstall(): bool

protected function getSchema(): Schema
{
return $this->schema ??= $this->db->getSchemaManager()->createSchema();
return $this->schema ??= $this->db->createSchemaManager()->introspectSchema();
}
}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"doctrine/annotations": "^1.13.1",
"doctrine/collections": "^1.6.5",
"doctrine/persistence": "^3.0.3",
"doctrine/dbal": "^3.4.2",
"doctrine/dbal": "^3.5",
"doctrine/doctrine-bundle": "^2.6.3",
"doctrine/doctrine-migrations-bundle": "^3.2.2",
"doctrine/inflector": "^2.0.2",
Expand Down
8 changes: 4 additions & 4 deletions lib/Targeting/Storage/DbStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public function all(VisitorInfo $visitorInfo, string $scope): array

$this->addExpiryParam($qb, $scope);

$stmt = $qb->execute();
$stmt = $qb->executeQuery();
$data = [];

if ($stmt instanceof Result) {
Expand Down Expand Up @@ -114,7 +114,7 @@ public function has(VisitorInfo $visitorInfo, string $scope, string $name): bool

$this->addExpiryParam($qb, $scope);

$stmt = $qb->execute();
$stmt = $qb->executeQuery();
$result = 0;

if ($stmt instanceof Result) {
Expand Down Expand Up @@ -179,7 +179,7 @@ public function get(VisitorInfo $visitorInfo, string $scope, string $name, mixed

$this->addExpiryParam($qb, $scope);

$stmt = $qb->execute();
$stmt = $qb->executeQuery();
$result = false;

if ($stmt instanceof Result) {
Expand Down Expand Up @@ -304,7 +304,7 @@ private function loadDate(VisitorInfo $visitorInfo, string $scope, string $selec

$this->addExpiryParam($qb, $scope);

$stmt = $qb->execute();
$stmt = $qb->executeQuery();

if ($stmt instanceof Result) {
return $this->convertToDateTime($stmt->fetchOne());
Expand Down
2 changes: 1 addition & 1 deletion tests/Support/Helper/Pimcore.php
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ protected function dropAndCreateDb(Connection $connection): void
// use a dedicated setup connection as the framework connection is bound to the DB and will
// fail if the DB doesn't exist
$setupConnection = DriverManager::getConnection($params, $config);
$schemaManager = $setupConnection->getSchemaManager();
$schemaManager = $setupConnection->createSchemaManager();

$databases = $schemaManager->listDatabases();
if (in_array($dbName, $databases)) {
Expand Down

0 comments on commit 631a520

Please sign in to comment.