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

Skip to content

Conflict symfony/validator 7.0 in symfony/doctrine-bridge 6.3 #51630

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 1 commit into from

Conversation

alexander-schranz
Copy link
Contributor

@alexander-schranz alexander-schranz commented Sep 11, 2023

Q A
Branch? 5.4 / 6.3 / 6.4 -> Revert in 7.0
Bug fix? yes
New feature? no
Deprecations? no
Tickets Fix #...
License MIT
Doc PR symfony/symfony-docs#...

Currently it is possible to have doctrine-bridge 6.3 and validator 7.0 installed which ends in the following error:

Testing PHP Fatal error: Declaration of Symfony\Bridge\Doctrine\Validator\DoctrineInitializer::initialize(object $object) must be compatible with Symfony\Component\Validator\ObjectInitializerInterface::initialize(object $object): void in /home/runner/work/sulu/sulu/vendor/symfony/doctrine-bridge/Validator/DoctrineInitializer.php on line 34

The conflict can be removed then on the 7.0 branch where the : void return type is added.

Tested it also appears on 5.4 branch so conflict there would also be good, rebased so to 5.4.

You maybe ask why symfony/doctrine-bridge was in my example not on 7.0. If a project still is using doctrine/persistence 2.0 instead of 3.0 it can not update the bridge to 6.4 or 7.0. So it could be a common error, to avoid this I suggest to add a conflict.

@carsonbot
Copy link

Hey!

Thanks for your PR. You are targeting branch "6.3" but it seems your PR description refers to branch "6.3 for features / 5.4, or 6.3 for bug fixes".
Could you update the PR description or change target branch? This helps core maintainers a lot.

Cheers!

Carsonbot

@@ -63,7 +63,7 @@
"symfony/proxy-manager-bridge": "<4.4.19",
"symfony/security-bundle": "<5",
"symfony/security-core": "<5.3",
"symfony/validator": "<5.4.25|>=6,<6.2.12|>=6.3,<6.3.1"
Copy link
Contributor Author

@alexander-schranz alexander-schranz Sep 11, 2023

Choose a reason for hiding this comment

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

Not sure if it would better to add a conflict to symfony/validator 7.0 as adding a conflict after a release in this case (5.4 and 6.3) will composer maybe just install a old version of the doctrine-bridge e.g. (5.4.28 or 6.3.4) without that conflict and then still run into the same error 🤔.

But it feels strange to add a conflict to symfony/validator as it has not even a optional dependency to the bridge.

Copy link
Member

Choose a reason for hiding this comment

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

I think we should add this conflict rule here (where it is legitimate), but we should also add it in validator 7.0 to avoid the issue of installing validator 7.0 and an outdated doctrine-bridge.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That would work I think. @nicolas-grekas what do you think about that?

@nicolas-grekas
Copy link
Member

This won't work: previous versions don't have the conflict so that composer might decide to install them instead of the latest 6.3.
Instead, what about removing the return type on 7.0 as advised in #51563?

@stof
Copy link
Member

stof commented Sep 12, 2023

@nicolas-grekas just removing the return type would fix compat with 7.0. But there is no conflict rule with 8.0 or 9.0 either so this cannot be the proper solution unless we avoid adding that return type forever.
See my proposal in the line comments for a solution that will work properly.

@nicolas-grekas
Copy link
Member

nicolas-grekas commented Sep 12, 2023

We bump deps in major version so that this guards naturally against such situations. Also, while we do seek for cross-majors compat between components, we don't between three majors. I would just add the return type in 8.0 and tell ppl that encounter the situation they have to update (6.3 will be EOLed since a long time) since this highly theoretical to me.

@stof
Copy link
Member

stof commented Sep 12, 2023

@nicolas-grekas this is a case of an optional dependency between components, for which our existing usages of conflict rules only restrict one side of the range (equivalent to use an optionalRequire on symfony/validator: >= 6.3.1 right now, so unbounded).

@nicolas-grekas
Copy link
Member

Sure, but still :) combining validator v8 with the bridge v6.3 should be an unsupported situation IMHO so I wouldn't care.

@alexander-schranz
Copy link
Contributor Author

For future we maybe could make sure to add all optional dependencies also to the conflict range to define the supported optional dependency versions. I did that for my search abstraction here: https://github.com/schranz-search/schranz-search/blob/48087364eb6b8b6e147bf475ed5bfb83bf77c88b/integrations/symfony/composer.json#L75-L85. But yeah that is just a solution for future incompatibility, for current I would go with @stof recommendation here if all others are fine with it: #51630 (comment)

@nicolas-grekas
Copy link
Member

nicolas-grekas commented Sep 12, 2023

I would go with @stof recommendation

We never do that AFAIK: making a component aware of a bridge (or if we do, that should be exceptionnal). That's broken package principles to me.

@stof
Copy link
Member

stof commented Sep 12, 2023

@nicolas-grekas we already made that in the past for conflict rules to handle the fact that we could not retro-actively add an upper bound to an optional dependency that was defined with a conflict rule allowing all future versions.

The way to avoid that (to respect package principles) would be that all our optional dependencies should forbid future major versions of that dependency with a conflict rule until we can ensure compatibility (basically avoiding unbounded optional dependencies)

@nicolas-grekas
Copy link
Member

nicolas-grekas commented Sep 12, 2023

That'd be too complex to manage I fear. I'm still up for the simple solution: revert the return type on v7, add it on v8 and don't care about what's going to be theoretical issue in 2/3 years. Alternatively, we could add the conflict in validator v7, but only that then. That's not my preference thought as it "pollutes" the deps of v7, while the point of a major is also to cleanup those things from the past.

@@ -63,7 +63,7 @@
"symfony/proxy-manager-bridge": "<4.4.19",
"symfony/security-bundle": "<5",
"symfony/security-core": "<5.3",
"symfony/validator": "<5.4.25|>=6,<6.2.12|>=6.3,<6.3.1"
"symfony/validator": "<5.4.25|>=6,<6.2.12|>=6.3,<6.3.1,>=7.0"
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"symfony/validator": "<5.4.25|>=6,<6.2.12|>=6.3,<6.3.1,>=7.0"
"symfony/validator": "<5.4.25|>=6,<6.2.12|>=6.3,<6.3.1|>=7.0"

@nicolas-grekas
Copy link
Member

I feel like y'all prefer the conflict-based approach, see #51634

nicolas-grekas added a commit that referenced this pull request Sep 12, 2023
…nicolas-grekas)

This PR was merged into the 7.0 branch.

Discussion
----------

[Validator] Make v7 conflict with doctrine-bridge < v7

| Q             | A
| ------------- | ---
| Branch?       | 7.0
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | -

Instead of #51630

Commits
-------

6b3e251 [Validator] Make v7 conflict with doctrine-bridge < v7
@alexander-schranz alexander-schranz deleted the patch-11 branch September 12, 2023 13:16
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