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] Run theResolveFactoryClassPass whenlint:container builds the container from a dump#50988

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

@MatTheCat
Copy link
Contributor

@MatTheCatMatTheCat commentedJul 15, 2023
edited
Loading

QA
Branch?6.3
Bug fix?yes
New feature?no
Deprecations?no
TicketsFix#50622
LicenseMIT
Doc PRN/A

#49665 replaced thefactory node by aconstructor attribute in the XML and YAML dumper when the factory’s class is the same as the definition’s. The corresponding loader then creates a definition where the factory class isnull.

As theResolveFactoryClassPass will not run when thelint:container command builds the container from an XML dump, such factories would makeContainerBuilder::createService crash. This PR adds this compiler pass to the list.

olife-png reacted with thumbs up emojilugosium reacted with hooray emoji
@lugosium
Copy link

I confirm your PR fix the issue 👍 🙏

Thanks a lot.

MatTheCat and olife-png reacted with thumbs up emoji

@nicolas-grekas
Copy link
Member

Did you consider enabling the pass on the command? That'd make more sense to me because if we do this, then we should do the same in PHP dumper, and the pass becomes useless. Also, this misses the check for $class that the pass has. WDYT ?

olife-png reacted with thumbs up emoji

@MatTheCat
Copy link
ContributorAuthor

TBH I didn’t consider updating the command because it looks like it must work without any compiler pass.

then we should do the same in PHP dumper

I may have missed something because I don’t understand why 🤔

olife-png reacted with thumbs up emoji

@nicolas-grekas
Copy link
Member

it looks like it must work without any compiler pass.

It never did before we introduced ResolveFactoryClassPass so I don't think so.

olife-png reacted with thumbs up emoji

@MatTheCat
Copy link
ContributorAuthor

Is this what you’re asking for?

diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/ContainerLintCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/ContainerLintCommand.php--- a/src/Symfony/Bundle/FrameworkBundle/Command/ContainerLintCommand.php(revision 6f2e603c176724873f92942ea7461150d0e32040)+++ b/src/Symfony/Bundle/FrameworkBundle/Command/ContainerLintCommand.php(date 1689424425782)@@ -20,6 +20,7 @@ use Symfony\Component\Console\Style\SymfonyStyle; use Symfony\Component\DependencyInjection\Compiler\CheckTypeDeclarationsPass; use Symfony\Component\DependencyInjection\Compiler\PassConfig;+use Symfony\Component\DependencyInjection\Compiler\ResolveFactoryClassPass; use Symfony\Component\DependencyInjection\Container; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;@@ -120,7 +121,7 @@             }              $container->getCompilerPassConfig()->setBeforeOptimizationPasses([]);-            $container->getCompilerPassConfig()->setOptimizationPasses([]);+            $container->getCompilerPassConfig()->setOptimizationPasses([new ResolveFactoryClassPass()]);             $container->getCompilerPassConfig()->setBeforeRemovingPasses([]);         }

It feels weird needing this particular pass to build the container from a dump.

olife-png reacted with thumbs up emoji

@MatTheCatMatTheCat changed the base branch from6.3 to5.4July 15, 2023 15:00
@MatTheCatMatTheCatforce-pushed thenull_factory_class_service branch 3 times, most recently fromfdd8a62 tod8afb57CompareJuly 15, 2023 15:54
@MatTheCatMatTheCat changed the base branch from5.4 to6.3July 15, 2023 15:54
@nicolas-grekas
Copy link
Member

nicolas-grekas commentedJul 15, 2023
edited
Loading

Yes that's what I mean. Dealing with th dumped XML requires special care, this makes sense to me. At least more than making the pass half-needeed. I prefer keeping the symmetry between the dumped container and a compiled container builder.

olife-png reacted with thumbs up emoji

@MatTheCatMatTheCatforce-pushed thenull_factory_class_service branch fromd8afb57 to5cf4b63CompareJuly 15, 2023 17:32
@MatTheCatMatTheCat changed the title[DependencyInjection] Handlenull factory class inContainerBuilder::createService[FrameworkBundle] Run theResolveFactoryClassPass whenlint:container builds the container from a dumpJul 15, 2023
@MatTheCat
Copy link
ContributorAuthor

Okay PR updated, thanks for the feedback 🙏

olife-png reacted with thumbs up emoji

@carsonbotcarsonbot changed the title[FrameworkBundle] Run theResolveFactoryClassPass whenlint:container builds the container from a dump[DependencyInjection] Run theResolveFactoryClassPass whenlint:container builds the container from a dumpJul 16, 2023
@nicolas-grekas
Copy link
Member

Thank you@MatTheCat.

@nicolas-grekasnicolas-grekas merged commit359fbc1 intosymfony:6.3Jul 16, 2023
@MatTheCatMatTheCat changed the title[DependencyInjection] Run theResolveFactoryClassPass whenlint:container builds the container from a dump[FrameworkBundle] Run theResolveFactoryClassPass whenlint:container builds the container from a dumpJul 16, 2023
@MatTheCatMatTheCat deleted the null_factory_class_service branchJuly 16, 2023 16:51
@fabpotfabpot mentioned this pull requestJul 30, 2023
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

@lyrixxlyrixxAwaiting requested review from lyrixx

@ycerutoycerutoAwaiting requested review from yceruto

@wouterjwouterjAwaiting requested review from wouterj

@chalasrchalasrAwaiting requested review from chalasr

@dunglasdunglasAwaiting requested review from dunglas

@OskarStarkOskarStarkAwaiting requested review from OskarStark

@xabbuhxabbuhAwaiting requested review from xabbuh

Assignees

No one assigned

Projects

None yet

Milestone

6.3

Development

Successfully merging this pull request may close these issues.

4 participants

@MatTheCat@lugosium@nicolas-grekas@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp