Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

[FrameworkBundle] Fix service reset between tests#58240

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

@HypeMC
Copy link
Member

QA
Branch?5.4
Bug fix?yes
New feature?no
Deprecations?no
Issues-
LicenseMIT

Currently, not all services are reset between tests. If a service uses the kernel.reset tag but does not implement the ResetInterface, it never gets reset.

if ($container->has('services_resetter')) {
$container->get('services_resetter')->reset();
}elseif ($containerinstanceof ResetInterface) {
$container->reset();
Copy link
Member

Choose a reason for hiding this comment

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

$container->reset() must still be called, to reset the instances hold by the container itself (see the code of line 302).

Btw, if you ensure that theservices_resetter service is instantiated, the container reset call will then call it (as ServiceResetter implements the ResetInterface).

The reason it was not called is becauseContainer::reset only resetsinstantiated resettable services

Copy link
MemberAuthor

@HypeMCHypeMCSep 12, 2024
edited
Loading

Choose a reason for hiding this comment

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

@stof Fixed, seehttps://github.com/symfony/symfony/compare/549ada5257c771da92d51aff76e224e1ac5d31f4..5491aa54a3205acfaf5ba62c134bddc26d794a36

Initially, I wanted to just instantiate theservices_resetter and letContainer::reset() call reset on it, but that didn’t work because theservices_resetter only resets instantiated services. Because of line 302, by the time it’s called, there aren’t any instantiated services left.

The downside of the current approach is that some services will get reset twice, but I don’t see a better solution at the moment.

Copy link
Member

Choose a reason for hiding this comment

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

ah indeed. The container resets itself before resetting the services.

I think this might actually be an issue if thereset method of a service triggers the instantiation of some other service. I think the resetting of the container state should probably be moved after the loop.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

@HypeMCHypeMCforce-pushed thefix-service-reset-between-tests branch 2 times, most recently from5491aa5 to53d0f56CompareSeptember 12, 2024 18:18
@HypeMCHypeMCforce-pushed thefix-service-reset-between-tests branch from53d0f56 tofb1ae1aCompareSeptember 12, 2024 20:01
@xabbuh
Copy link
Member

Isn’t the test failure on PHP 8.2 related?

@HypeMC
Copy link
MemberAuthor

Isn’t the test failure on PHP 8.2 related?

@xabbuh Yes, but that's high-deps and if I'm not mistaking, that'll get resolved when merged upstream.

@nicolas-grekas
Copy link
Member

Thank you@HypeMC.

@nicolas-grekasnicolas-grekas merged commitb2201c3 intosymfony:5.4Sep 16, 2024
@HypeMCHypeMC deleted the fix-service-reset-between-tests branchSeptember 16, 2024 13:50
xabbuh added a commit that referenced this pull requestSep 20, 2024
…nel is shut down (jderusse)This PR was merged into the 5.4 branch.Discussion----------[FrameworkBundle] Do not access the container when the kernel is shut down| Q             | A| ------------- | ---| Branch?       | 5.4| Bug fix?      | yes| New feature?  | no| Deprecations? | no| Issues        | -| License       | MIT#58240 play with the container after the kernel was shut down.This is an issue when the kernel performs a cleanup operation. For instance, the `@Nyholm` TestBundle [deletes cache files](https://github.com/SymfonyTest/symfony-bundle-test/blob/241bf0e2f00f28f7327113570ab20e24a5828829/src/TestKernel.php#L184-L199) as a result, the service is not accessible anymore and triggers errors.This PR move the call to `container->get` before `kernel::shutdown`Commits-------e68f88c [FrameworkBundle] Do not access the container when the kernel is shut down
This was referencedSep 21, 2024
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@OskarStarkOskarStarkOskarStark left review comments

@xabbuhxabbuhxabbuh left review comments

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

@stofstofstof approved these changes

Assignees

No one assigned

Projects

None yet

Milestone

5.4

Development

Successfully merging this pull request may close these issues.

6 participants

@HypeMC@xabbuh@nicolas-grekas@stof@OskarStark@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp