Skip to content

Commit bc77171

Browse files
Merge branch '6.4' into 7.0
* 6.4: [AssetMapper] Allow simple, relative paths in importmap.php [PropertyInfo] Make isWriteable() more consistent with isReadable() when checking snake_case properties [AssetMapper] Add support for CSS files in the importmap [Messenger] Add `--all` option to the `messenger:failed:remove` command Fix merge fix #51235 - fix the order of merging of serializationContext and self::CONTEXT_DENORMALIZE [HttpClient] Fix Static Code Analyzer issue with JsonMockResponse [Messenger] Fix exiting `FailedMessagesRetryCommand` [Serializer] Fix reindex normalizedData array in AbstractObjectNormalizer::denormalize() remove an unreachable code branch [Validator] Fix `File::$extensions`’ PHPDoc [Mime] Fix email (de)serialization issues [FrameworkBundle][WebProfilerBundle][Console][Form][HttpKernel][PropertyInfo][Validator] Remove optional before required param Replace usages of SkippedTestSuiteError with markTestSkipped() call Update InteractiveAuthenticatorInterface description wording to match documentation [Serializer] Fix parsing XML root node attributes fix parsing of payload timestamp to DateTimeImmutable Fix routing to multiple fallback transports Fix missing stamps in delayed message handling [DoctrineBridge] Ignore invalid stores in `LockStoreSchemaListener` raised by `StoreFactory`
2 parents eb70822 + fb7ebea commit bc77171

File tree

2 files changed

+30
-4
lines changed

2 files changed

+30
-4
lines changed

SchemaListener/LockStoreSchemaListener.php

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

1414
use Doctrine\ORM\Tools\Event\GenerateSchemaEventArgs;
15+
use Symfony\Component\Lock\Exception\InvalidArgumentException;
1516
use Symfony\Component\Lock\PersistingStoreInterface;
1617
use Symfony\Component\Lock\Store\DoctrineDbalStore;
1718

@@ -28,12 +29,20 @@ public function postGenerateSchema(GenerateSchemaEventArgs $event): void
2829
{
2930
$connection = $event->getEntityManager()->getConnection();
3031

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

36-
$store->configureSchema($event->getSchema(), $this->getIsSameDatabaseChecker($connection));
45+
$storesIterator->next();
3746
}
3847
}
3948
}

Tests/SchemaListener/LockStoreSchemaListenerTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
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;
2021
use Symfony\Component\Lock\Store\DoctrineDbalStore;
2122

2223
class LockStoreSchemaListenerTest extends TestCase
@@ -39,4 +40,20 @@ public function testPostGenerateSchemaLockPdo()
3940
$subscriber = new LockStoreSchemaListener([$lockStore]);
4041
$subscriber->postGenerateSchema($event);
4142
}
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+
})());
57+
$subscriber->postGenerateSchema($event);
58+
}
4259
}

0 commit comments

Comments
 (0)