Skip to content
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

Allow symfony 7 dependencies #395

Merged
merged 3 commits into from
Sep 12, 2023
Merged

Conversation

weaverryan
Copy link
Contributor

@weaverryan weaverryan commented Sep 12, 2023

Hi!

Allowing Symfony 7 dependencies to be installed.

This requires a BC break: to stop using the deprecated ContainerAwareLoader.

Do we want to TRY to have a BC-layer? It would require, I think, some config where the user "turns off" the ContainerAwareLoader to silence the deprecation. Honestly, I don't think anyone has used container-aware loaders for a long time - requiring an option sounds annoying for users. I'd vote for a new 4.0 with this change, but I'll defer to what others think is best.

If we did a new major, we could also very easily drop old php & Symfony versions.

Cheers!


use function array_key_exists;
use function array_values;
use function get_class;
use function sprintf;

final class SymfonyFixturesLoader extends ContainerAwareLoader
final class SymfonyFixturesLoader extends Loader
Copy link
Member

@greg0ire greg0ire Sep 12, 2023

Choose a reason for hiding this comment

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

Is this a breaking change? How will it affect people still using Symfony 6? According to the deprecation message embedded in the bridge class, people should first "use dependency injection in [their] fixtures instead".

Copy link
Member

Choose a reason for hiding this comment

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

Ah, just saw you edited the description :)

@greg0ire
Copy link
Member

greg0ire commented Sep 12, 2023

Honestly, I don't think anyone has used container-aware loaders for a long time - requiring an option sounds annoying for users.

I'm not sure this is the point: people relying on container-aware fixtures get the very same deprecation as people not relying on it. It might have been better to wrap the injected container with a wrapper that triggers a deprecation whenever somebody calls get() or has() on that container, but I guess that ship has sailed :)

I think there is a way to do this without a breaking change though:

  1. create a file that conditionally declares a class, depending on whether ContainerAwareLoader exists or not.
if (class_exists(ContainerAwareLoader)) {
    class IntermediaryContainer extends ContainerAwareLoader {}
} else {
    class IntermediaryContainer extends Container {}
}
  1. extend that class in SymfonyFixturesLoader

As a result, people with Symfony 6 will not be affected, and people with Symfony 7 cannot complain since they got a deprecation about this issue.

The deprecation is used in an execution path that is unlikely to be overused, and I agree that developing something to turn it off might be overkill.

@weaverryan
Copy link
Contributor Author

Thanks for considering this with me :). If we do the conditional class:

if (class_exists(ContainerAwareLoader)) {
    class IntermediaryLoader extends ContainerAwareLoader {}
} else {
    class IntermediaryLoader extends Loader {}
}

Won't people using Symfony 6.4 get a deprecation warning that they can't silence? The ContainerAwareLoader class will exist, so it'll be extended, and that'll trigger the deprecation warning on that class, right? If I am, we would need some bundle config to "disable" extending that class. That's the part that sounds annoying for the 99% of users that probably haven't used container-aware loaders for awhile.

@greg0ire
Copy link
Member

Fully agree with you, but:

The deprecation is used in an execution path that is unlikely to be overused, and I agree that developing something to turn it off might be overkill.

That being said, I just pushed 4.0.x, because in any case, there will need to be a contribution on that branch soon (either a cleanup, or we just retarget your PR).

Ideally, it would be cool to have a way for users to opt-out, but I can't see how to embed such a condition inside if (class_exists(ContainerAwareLoader)) 🤔 . I think such situations will always happen if we use extends and a class from another package.

@weaverryan weaverryan changed the base branch from 3.5.x to 4.0.x September 12, 2023 15:08
@weaverryan
Copy link
Contributor Author

I've just retargeted the branch to 4.0.x. It is, at least, a good starting point. For a new major, we can also drop old php & Symfony versions. Keep that separate from this PR or embed it?

@greg0ire greg0ire added this to the 4.0.0 milestone Sep 12, 2023
@greg0ire greg0ire merged commit 1e3b85f into doctrine:4.0.x Sep 12, 2023
17 checks passed
@greg0ire
Copy link
Member

Let's go with separate PRs :)

@OrestisZag
Copy link

@greg0ire @weaverryan Great work with this. 😄 Are you gonna tag this soon or is there some other issue? Thank you!

@derrabus
Copy link
Member

We don't plan to release 4.0 anytime soon. Use 3.5.

@OrestisZag
Copy link

@derrabus thanks for your answer. This is needed for Symfony 6.4, right? Or is there another way to proceed?

@derrabus
Copy link
Member

Or is there another way to proceed?

There is. Use 3.5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants