Skip to content

[Messenger] Move doctrine deps to require-dev #36785

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
merged 1 commit into from
May 16, 2020

Conversation

tyx
Copy link
Contributor

@tyx tyx commented May 12, 2020

Q A
Branch? master
Bug fix? yes
New feature? no
Deprecations? no
Tickets Fix #36740
License MIT

To avoid requiring all doctrine stuff when require symfony/messenger
(that require symfony/doctrine-messenger to ensure BC)

@tyx tyx force-pushed the fix/doctrine-messenger branch from aebe6d1 to 35579f1 Compare May 12, 2020 09:26
Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

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

Wait, no, this is not correct, this bridge has to require these.

What could be changed is the composer.json of the messenger component itself: it should maybe not list any symfony/*-messenger. Instead, ppl should install each bridge they use.

To make things smooth, legacy classes in Transport (eg https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Messenger/Transport/Doctrine/DoctrineTransport.php) should throw a LogicException telling which bridge ppl should install.

@tyx
Copy link
Contributor Author

tyx commented May 12, 2020

CI Failures seems unrelated

@tyx
Copy link
Contributor Author

tyx commented May 12, 2020

@nicolas-grekas I'm 👍 with this solution also. But is it not too "hard" for an minor update ?

@nicolas-grekas
Copy link
Member

nicolas-grekas commented May 12, 2020

We did it before, this is trivially fixed by ppl that will be affected - and this is not covered by the BC policy :)

@Nyholm
Copy link
Member

Nyholm commented May 12, 2020

After sleeping on this and some discussions with Nicolas. I think I was wrong with #36740 (comment)

This is the proper wrong way forward:

Remove these dependencies from symfony/messenger:

 "symfony/amqp-messenger": "^5.1",
 "symfony/doctrine-messenger": "^5.1",
 "symfony/redis-messenger": "^5.1"

This will do two things:

  1. It will allow us to specify ext-amqp, ext-redis and doctrine dependencies in the bridges.
  2. Force the user to run composer require symfony/*-messenger.

We want to create a nice message for the user in build time so the user knows they need to run composer require. To do that, we need to throw an exception when:

  • the deprecated classes in Symfony\Component\Messenger\Transport is being used AND
  • the new transport is missing.

@tyx, could you please update this PR?

@nicolas-grekas
Copy link
Member

Hm, after talking with @fabpot, we settled on your approach. Can you please add some LogicException thrown when dbal is not installed? See the other bridges for inspiration, they do something similar already.

@nicolas-grekas
Copy link
Member

Oh, I posted my comment without noticing yours @Nyholm
The approach I proposed (and you mention in your comment) is cleaner, but the approach you implemented is smoother. I changed my mind and I think you did the right thing then, it's very pragmatic.

I'm OK with removing dbal/etc from the doctrine-messenger bridge. We just need these extra LogicException I mentioned in my previous comment.

Sorry for the confusion.

@tyx
Copy link
Contributor Author

tyx commented May 13, 2020

Hi !

So just to be sure I understand:

  • We keep the current behavior implemented here (aka removing dbal from doctrine/messenger)
  • I need to throw an exception on new DoctrineTransport present in the new bridge when dbal is missing.

@nicolas-grekas
Copy link
Member

Correct, for persistence also

@tyx tyx force-pushed the fix/doctrine-messenger branch from 35579f1 to 33d65dc Compare May 13, 2020 19:34
@tyx
Copy link
Contributor Author

tyx commented May 13, 2020

Ok, I updated with the check asked.
I failed to find same usecase in other bridge, so feel free to correct me !

@shouze
Copy link

shouze commented May 14, 2020

@tyx and some tests are now failing because of the exception

@Nyholm
Copy link
Member

Nyholm commented May 14, 2020

I think we need to throw exception when the class is used. Currently we throw them when the class is loaded.

@stof
Copy link
Member

stof commented May 14, 2020

If we remove the requirements in the bridge and we ask projects to require doctrine/dbal and doctrine/persistence themselves, we are actually not making them prepare for the state we want in Symfony 6, where symfony/messenger does not force installing bridges (otherwise, we should drop the bridges entirely and put these classes directly in symfony/messenger). So the migration path being implemented here looks like the wrong one to me.

@Nyholm
Copy link
Member

Nyholm commented May 14, 2020

The bridges were a part of symfony/messenger in 5.0. We did not have any checks if doctrine was installed.

When the bridges was moved to a separate package we (mistakenly) added doctrine dependencies. That lead to us forcing the user to install doctrine when they wanted symfony/messegner.

@stof, We want to have the same behaviour as SF 5.0 and a smooth upgrade path.

@stof
Copy link
Member

stof commented May 14, 2020

@Nyholm this won't be a smooth upgrade path to 5.0, as you will never tell users to add a requirement on the new bridge (which is what they need to do to upgrade to them in a future-proof way)

@Nyholm
Copy link
Member

Nyholm commented May 14, 2020 via email

To avoid requiring all doctrine stuff when require symfony/messenger
(that require symfony/doctrine-messenger to ensure BC)
@nicolas-grekas nicolas-grekas force-pushed the fix/doctrine-messenger branch from 33d65dc to b73b26e Compare May 14, 2020 15:53
@nicolas-grekas nicolas-grekas changed the title [Messenger] Move doctrine deps to require-dev until 6.0 [Messenger] Move doctrine deps to require-dev May 14, 2020
Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

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

Actually, because dbal and persistence are only used in constructors, they will never need to be in "require", even in 6.0. The reason is that you cannot instantiate the bridge if you don't have them already.

The good thing is that the wiring happens in doctrine-bundle, where dbal+persistence are already required.

This means this is perfect as is.

@nicolas-grekas
Copy link
Member

this won't be a smooth upgrade path to 5.0, as you will never tell users to add a requirement on the new bridge

@stof that's true. There is no better way IMHO. Either we ask ppl to require the bridge now, or we postpone this for 6.0.

In 6.0 is the smoothest to me. Ppl will quickly figure our anyway.

@stof
Copy link
Member

stof commented May 14, 2020

@nicolas-grekas The third solution is to keep the deprecated class independent of the new class. So they will need to require the new packages when migrating to the new classes (as that would be the way to get the new classes).

Are you sure? There are already deprecation notices telling you to require the new package.

They can totally use the new classes without doing that, relying on the transitive dependency of symfony/messenger adding those bridges.

@nicolas-grekas
Copy link
Member

nicolas-grekas commented May 14, 2020

The third solution is to keep the deprecated class independent of the new class

Hmm. Duplicating the code, right?
That'd be quite annoying to maintain, ensuring bug fixes are correctly applied to both files.

I think we're good enough with the current approach, let's take the simple path for us once :)

@nicolas-grekas
Copy link
Member

Thank you @tyx.

@nicolas-grekas nicolas-grekas merged commit 02cedc3 into symfony:master May 16, 2020
@tyx tyx deleted the fix/doctrine-messenger branch May 18, 2020 09:16
fabpot added a commit that referenced this pull request Aug 13, 2020
…alling symfony/messenger (ogizanagi)

This PR was merged into the 5.2-dev branch.

Discussion
----------

[Messenger] Don't require doctrine/persistence when installing symfony/messenger

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | no <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tickets       | Fix #36790 <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead -->
| License       | MIT
| Doc PR        | N/A

As of today, [installing `symfony/messenger` installs `symfony/doctrine-messenger`](https://github.com/symfony/symfony/blob/3867fb2489ef0d07dec4859cf461bb7bcc7618e0/src/Symfony/Component/Messenger/composer.json#L23) as well. Which means adding `doctrine/persistence` as a hard dep of the latest will install it for any user requiring `symfony/messenger` in 5.2.

I think it should stay a soft-dependency until we remove `symfony/doctrine-messenger` as a `symfony/messenger` dependency as of Symfony 6.0 (as mentioned in #35422).

---

related: #36785

Commits
-------

5c05455 [Messenger] Don't require doctrine/persistence when installing symfony/messenger
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.

[Messenger] Do not require doctrine/messenger
8 participants