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

[DependencyInjection] Always preload services classes tagged with container.preload#36742

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

Closed

Conversation

@fancyweb
Copy link
Contributor

QA
Branch?master
Bug fix?no
New feature?yes
Deprecations?no
Tickets-
LicenseMIT
Doc PR-

This PR aims to solve the case where you want to force the preload of a service class even if the service definition has thecontainer.no_preload tag.

For example, inRegisterListenersPass, we add thecontainer.no_preload tag on definitions that listen to some particular events. What if I want to force the preload of those services classes anyway?

Adding thecontainer.preload tag does not work because the "no preload" behavior has the priority. I propose to change that so one can simply add the tag when he wants to override Symfony's default behavior.

Moreover, to not repeat the service class on thecontainer.preloadclass attribute, let's make this attribute optional. When it's not there, it means I want to preload the service class.

@fancywebfancyweb changed the title[DependencyInjection] Preload services classes tagged with container.preload[DependencyInjection] Always preload services classes tagged with container.preloadMay 7, 2020
$dump =str_replace('\\\\Fixtures\\\\includes\\\\foo.php','/Fixtures/includes/foo.php',$dump);
}
$this->assertStringMatchesFormatFile(self::$fixturesPath.'/php/services9_as_files.txt',$dump);
$this->assertStringEqualsFile(self::$fixturesPath.'/php/services9_as_files.txt',$dump);
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

We can't use a regex anymore because the file to compare to have become too big (preg_match(): Compilation failed: regular expression is too large at offset 35752). I guess this strategy is useful when merging from lower branches? Do someone have a better idea than strict comparison or creating a new file? 😕

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Tests are failing: I need to recheck the strategy.

->addTag('container.preload', ['class' =>'Some\Sidekick1'])
->addTag('container.preload', ['class' =>'Some\Sidekick2']);

$container->register('no_preload','TestNoPreload')
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

I also added a test withcontainer.no_preload as I think it was not tested.

@nicolas-grekas
Copy link
Member

I feel like we might not need this PR after#36749

At least the case we built this solution for (ConsoleHandler) is fixed by it. And if we don't have a use case anymore, it's better to not do this I realize now.

Agreed?

@fancyweb
Copy link
ContributorAuthor

I agree, it's better.

@fancywebfancyweb deleted the di-preload-priority branchMay 11, 2020 13:20
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

5.1

Development

Successfully merging this pull request may close these issues.

3 participants

@fancyweb@nicolas-grekas@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp