Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[DoctrineBridge] Fix LockStoreSchemaListener not working properly with iterable objects #54407

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Revert "[DoctrineBridge] Ignore invalid stores in `LockStoreSchemaLis…
…tener` raised by `StoreFactory`"

This reverts commit 0acd403.
  • Loading branch information
barton-webwings committed Mar 27, 2024
commit d6b4d8465543b0587093b7de81bc0a0dad379a73
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
namespace Symfony\Bridge\Doctrine\SchemaListener;

use Doctrine\ORM\Tools\Event\GenerateSchemaEventArgs;
use Symfony\Component\Lock\Exception\InvalidArgumentException;
use Symfony\Component\Lock\PersistingStoreInterface;
use Symfony\Component\Lock\Store\DoctrineDbalStore;

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

$storesIterator = new \ArrayIterator($this->stores);
while ($storesIterator->valid()) {
try {
$store = $storesIterator->current();
if (!$store instanceof DoctrineDbalStore) {
continue;
}

$store->configureSchema($event->getSchema(), $this->getIsSameDatabaseChecker($connection));
} catch (InvalidArgumentException) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we still need catch the exception to not reintroduce the bug that #50761 tried to fix

// no-op
foreach ($this->stores as $store) {
if (!$store instanceof DoctrineDbalStore) {
continue;
}

$storesIterator->next();
$store->configureSchema($event->getSchema(), $this->getIsSameDatabaseChecker($connection));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
use Doctrine\ORM\Tools\Event\GenerateSchemaEventArgs;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\Doctrine\SchemaListener\LockStoreSchemaListener;
use Symfony\Component\Lock\Exception\InvalidArgumentException;
use Symfony\Component\Lock\Store\DoctrineDbalStore;

class LockStoreSchemaListenerTest extends TestCase
Expand All @@ -40,20 +39,4 @@ public function testPostGenerateSchemaLockPdo()
$subscriber = new LockStoreSchemaListener([$lockStore]);
$subscriber->postGenerateSchema($event);
}

public function testPostGenerateSchemaWithInvalidLockStore()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this test should be kept as fixing the issue #50761 tried to fix is legitimate

{
$entityManager = $this->createMock(EntityManagerInterface::class);
$entityManager->expects($this->once())
->method('getConnection')
->willReturn($this->createMock(Connection::class));
$event = new GenerateSchemaEventArgs($entityManager, new Schema());

$subscriber = new LockStoreSchemaListener((static function (): \Generator {
yield $this->createMock(DoctrineDbalStore::class);

throw new InvalidArgumentException('Unsupported Connection');
})());
$subscriber->postGenerateSchema($event);
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.