Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[DoctrineBridge] Ignore invalid stores in LockStoreSchemaListener raised by StoreFactory #50761

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

Merged

Conversation

alexandre-daubois
Copy link
Member

Q A
Branch? 6.3
Bug fix? yes
New feature? no
Deprecations? no
Tickets NA
License MIT
Doc PR NA

In our test environment, we're setting our LOCK_DSN env var at null. This works well in 6.2 but not in 6.3 anymore.

The version 6.3 of DoctrineBridge is bringing this BC break. Indeed, lock stores are being injected in Symfony\Bridge\Doctrine\SchemaListener\LockStoreSchemaListener. At runtime, the StoreFactory is used to instantiate stores when they are needed in postGenerateSchema.

Unfortunately, our LOCK_DSN=null doesn't match any case in StoreFactory, which has the effect to throw Symfony\Component\Lock\Exception\InvalidArgumentException, which is not catched in LockStoreSchemaListener.

This PR takes care of this: at this time, LockStoreSchemaListener only deals with DoctrineDbalStore. I think it is safe to ignore any instantiation problem that may occur in the StoreFactory.

foreach ($this->stores as $store) {
if (!$store instanceof DoctrineDbalStore) {
continue;
$storesIterator = new \ArrayIterator($this->stores);
Copy link
Member

Choose a reason for hiding this comment

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

should be IteratorIterator ?

Copy link
Member

Choose a reason for hiding this comment

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

hum, no, because arrays

@nicolas-grekas
Copy link
Member

Thank you @alexandre-daubois.

@nicolas-grekas nicolas-grekas merged commit 69ef02e into symfony:6.3 Sep 29, 2023
@fabpot fabpot mentioned this pull request Sep 30, 2023
@tourze
Copy link
Contributor

tourze commented Oct 19, 2023

This PR make some error while using DoctrineDbalStore, in \Symfony\Bridge\Doctrine\SchemaListener\LockStoreSchemaListener.

See these two picture, iterator_count is greater than zero, but dump(111); is not working as expect.

WX20231019-182853

WX20231019-182944

@stof
Copy link
Member

stof commented Oct 19, 2023

iterator_count will iterate the iterator. So by adding your dump, you modified the behavior of the method here (as you don't rewind the iterator after counting it)

@tourze
Copy link
Contributor

tourze commented Oct 19, 2023

After downgrade symfony/doctrine-bridge to 6.3.4, works fine.
WX20231019-184251

@tourze
Copy link
Contributor

tourze commented Oct 19, 2023

iterator_count will iterate the iterator. So by adding your dump, you modified the behavior of the method here (as you don't rewind the iterator after counting it)

remove iterator_count , still error.

WX20231019-184712

MatTheCat added a commit to MatTheCat/symfony that referenced this pull request Aug 8, 2024
…LockStoreSchemaListener` raised by `StoreFactory` (alexandre-daubois)"

This reverts commit 69ef02e, reversing
changes made to 04c7ccf.
MatTheCat added a commit to MatTheCat/symfony that referenced this pull request Aug 8, 2024
…LockStoreSchemaListener` raised by `StoreFactory` (alexandre-daubois)"

This reverts commit 69ef02e, reversing
changes made to 04c7ccf.
MatTheCat added a commit to MatTheCat/symfony that referenced this pull request Aug 8, 2024
…LockStoreSchemaListener` raised by `StoreFactory` (alexandre-daubois)"

This reverts commit 69ef02e, reversing
changes made to 04c7ccf.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants