Skip to content

Commit

Permalink
[DoctrineBridge]rm BC layer configureSchema check database
Browse files Browse the repository at this point in the history
  • Loading branch information
alli83 committed Jun 27, 2023
1 parent 0d737cf commit 7a8a8bf
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 22 deletions.
16 changes: 16 additions & 0 deletions UPGRADE-7.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ Symfony 6.4 and Symfony 7.0 will be released simultaneously at the end of Novemb
release process, both versions will have the same features, but Symfony 7.0 won't include any deprecated features.
To upgrade, make sure to resolve all deprecation notices.

Cache
-----

* Add parameter `$isSameDatabase` to `DoctrineDbalAdapter::configureSchema()`

DoctrineBridge
--------------

Expand All @@ -15,6 +20,17 @@ DoctrineBridge
* Remove `DoctrineDataCollector::addLogger()`, use a `DebugDataHolder` instead
* `ContainerAwareEventManager::getListeners()` must be called with an event name
* DoctrineBridge now requires `doctrine/event-manager:^2`
* Add parameter `$isSameDatabase` to `DoctrineTokenProvider::configureSchema()`

Lock
----

* Add parameter `$isSameDatabase` to `DoctrineDbalStore::configureSchema()`

Messenger
---------

* Add parameter `$isSameDatabase` to `DoctrineTransport::configureSchema()`

ProxyManagerBridge
------------------
Expand Down
1 change: 1 addition & 0 deletions src/Symfony/Bridge/Doctrine/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ CHANGELOG
* Remove `DoctrineDataCollector::addLogger()`, use a `DebugDataHolder` instead
* `ContainerAwareEventManager::getListeners()` must be called with an event name
* DoctrineBridge now requires `doctrine/event-manager:^2`
* Add parameter `$isSameDatabase` to `DoctrineTokenProvider::configureSchema()`

6.4
---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,17 +179,13 @@ public function updateExistingToken(PersistentTokenInterface $token, #[\Sensitiv

/**
* Adds the Table to the Schema if "remember me" uses this Connection.
*
* @param \Closure $isSameDatabase
*/
public function configureSchema(Schema $schema, Connection $forConnection/* , \Closure $isSameDatabase */): void
public function configureSchema(Schema $schema, Connection $forConnection, \Closure $isSameDatabase): void
{
if ($schema->hasTable('rememberme_token')) {
return;
}

$isSameDatabase = 2 < \func_num_args() ? func_get_arg(2) : static fn () => false;

if ($forConnection !== $this->conn && !$isSameDatabase($this->conn->executeStatement(...))) {
return;
}
Expand Down
7 changes: 1 addition & 6 deletions src/Symfony/Component/Cache/Adapter/DoctrineDbalAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,17 +117,12 @@ public function createTable(): void
}
}

/**
* @param \Closure $isSameDatabase
*/
public function configureSchema(Schema $schema, Connection $forConnection/* , \Closure $isSameDatabase */): void
public function configureSchema(Schema $schema, Connection $forConnection, \Closure $isSameDatabase): void
{
if ($schema->hasTable($this->table)) {
return;
}

$isSameDatabase = 2 < \func_num_args() ? func_get_arg(2) : static fn () => false;

if ($forConnection !== $this->conn && !$isSameDatabase($this->conn->executeStatement(...))) {
return;
}
Expand Down
5 changes: 5 additions & 0 deletions src/Symfony/Component/Cache/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
CHANGELOG
=========

7.0
---

* Add parameter `$isSameDatabase` to `DoctrineDbalAdapter::configureSchema()`

6.3
---

Expand Down
5 changes: 5 additions & 0 deletions src/Symfony/Component/Lock/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
CHANGELOG
=========

7.0
---

* Add parameter `$isSameDatabase` to `DoctrineDbalStore::configureSchema()`

6.3
---

Expand Down
8 changes: 2 additions & 6 deletions src/Symfony/Component/Lock/Store/DoctrineDbalStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ public function exists(Key $key): bool
public function createTable(): void
{
$schema = new Schema();
$this->configureSchema($schema);
$this->configureSchema($schema, static fn () => true);

foreach ($schema->toSql($this->conn->getDatabasePlatform()) as $sql) {
$this->conn->executeStatement($sql);
Expand All @@ -208,17 +208,13 @@ public function createTable(): void

/**
* Adds the Table to the Schema if it doesn't exist.
*
* @param \Closure $isSameDatabase
*/
public function configureSchema(Schema $schema/* , \Closure $isSameDatabase */): void
public function configureSchema(Schema $schema, \Closure $isSameDatabase): void
{
if ($schema->hasTable($this->table)) {
return;
}

$isSameDatabase = 1 < \func_num_args() ? func_get_arg(1) : static fn () => true;

if (!$isSameDatabase($this->conn->executeStatement(...))) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,9 @@ public function setup(): void

/**
* Adds the Table to the Schema if this transport uses this connection.
*
* @param \Closure $isSameDatabase
*/
public function configureSchema(Schema $schema, DbalConnection $forConnection/* , \Closure $isSameDatabase */): void
public function configureSchema(Schema $schema, DbalConnection $forConnection, \Closure $isSameDatabase): void
{
$isSameDatabase = 2 < \func_num_args() ? func_get_arg(2) : static fn () => false;

$this->connection->configureSchema($schema, $forConnection, $isSameDatabase);
}

Expand Down
5 changes: 5 additions & 0 deletions src/Symfony/Component/Messenger/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
CHANGELOG
=========

7.0
---

* Add parameter `$isSameDatabase` to `DoctrineTransport::configureSchema()`

6.3
---

Expand Down

0 comments on commit 7a8a8bf

Please sign in to comment.