Skip to content

Commit d5f7171

Browse files
bug #57944 [DoctrineBridge] Fix the LockStoreSchemaListener (MatTheCat)
This PR was squashed before being merged into the 6.4 branch. Discussion ---------- [DoctrineBridge] Fix the `LockStoreSchemaListener` | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | Fix #54406 | License | MIT #54407 got sidetracked ~and `@barton`-webwings seems no longer active on GitHub~ so this PR takes over. Commits ------- db070a1 [DoctrineBridge] Fix the `LockStoreSchemaListener`
2 parents 73d8b75 + db070a1 commit d5f7171

File tree

2 files changed

+5
-31
lines changed

2 files changed

+5
-31
lines changed

src/Symfony/Bridge/Doctrine/SchemaListener/LockStoreSchemaListener.php

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace Symfony\Bridge\Doctrine\SchemaListener;
1313

1414
use Doctrine\ORM\Tools\Event\GenerateSchemaEventArgs;
15-
use Symfony\Component\Lock\Exception\InvalidArgumentException;
1615
use Symfony\Component\Lock\PersistingStoreInterface;
1716
use Symfony\Component\Lock\Store\DoctrineDbalStore;
1817

@@ -30,20 +29,12 @@ public function postGenerateSchema(GenerateSchemaEventArgs $event): void
3029
{
3130
$connection = $event->getEntityManager()->getConnection();
3231

33-
$storesIterator = new \ArrayIterator($this->stores);
34-
while ($storesIterator->valid()) {
35-
try {
36-
$store = $storesIterator->current();
37-
if (!$store instanceof DoctrineDbalStore) {
38-
continue;
39-
}
40-
41-
$store->configureSchema($event->getSchema(), $this->getIsSameDatabaseChecker($connection));
42-
} catch (InvalidArgumentException) {
43-
// no-op
32+
foreach ($this->stores as $store) {
33+
if (!$store instanceof DoctrineDbalStore) {
34+
continue;
4435
}
4536

46-
$storesIterator->next();
37+
$store->configureSchema($event->getSchema(), $this->getIsSameDatabaseChecker($connection));
4738
}
4839
}
4940
}

src/Symfony/Bridge/Doctrine/Tests/SchemaListener/LockStoreSchemaListenerTest.php

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
use Doctrine\ORM\Tools\Event\GenerateSchemaEventArgs;
1818
use PHPUnit\Framework\TestCase;
1919
use Symfony\Bridge\Doctrine\SchemaListener\LockStoreSchemaListener;
20-
use Symfony\Component\Lock\Exception\InvalidArgumentException;
2120
use Symfony\Component\Lock\Store\DoctrineDbalStore;
2221

2322
class LockStoreSchemaListenerTest extends TestCase
@@ -37,23 +36,7 @@ public function testPostGenerateSchemaLockPdo()
3736
->method('configureSchema')
3837
->with($schema, fn () => true);
3938

40-
$subscriber = new LockStoreSchemaListener([$lockStore]);
41-
$subscriber->postGenerateSchema($event);
42-
}
43-
44-
public function testPostGenerateSchemaWithInvalidLockStore()
45-
{
46-
$entityManager = $this->createMock(EntityManagerInterface::class);
47-
$entityManager->expects($this->once())
48-
->method('getConnection')
49-
->willReturn($this->createMock(Connection::class));
50-
$event = new GenerateSchemaEventArgs($entityManager, new Schema());
51-
52-
$subscriber = new LockStoreSchemaListener((static function (): \Generator {
53-
yield $this->createMock(DoctrineDbalStore::class);
54-
55-
throw new InvalidArgumentException('Unsupported Connection');
56-
})());
39+
$subscriber = new LockStoreSchemaListener((static fn () => yield $lockStore)());
5740
$subscriber->postGenerateSchema($event);
5841
}
5942
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy