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

ResolveBindingsPass: Don't throw error for unused service, missing parent class#27088

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

@weaverryan
Copy link
Member

QA
Branch?3.4
Bug fix?yes
New feature?no
BC breaks?no
Deprecations?no->
Tests pass?yes
Fixed ticketssymfony/flex#346 (comment)
LicenseMIT
Doc PRn/a

Hey guys!

In short: if you:

A) auto-register a class as a service
B) That class's parent class is missing
C) ... but this class/service is unused

Currently,ResolveBindingsPass will fail and throw an exception. The change avoids that - only throwing the exception if the service IS used. This is already done inAutowirePass.

The real issue is DoctrineFixturesBundle, where, on production, the bundle (and so,Fixtures base class) is not installed, causing a build error, even though these service classes are unused.

Cheers!

Gemorroj and jeroendesloovere reacted with thumbs up emoji
This mirrors what was already done in AutowirePass
Copy link
Member

@nicolas-grekasnicolas-grekas left a comment

Choose a reason for hiding this comment

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

Good catch

@nicolas-grekas
Copy link
Member

Thank you@weaverryan.

@nicolas-grekasnicolas-grekas merged commit309da92 intosymfony:3.4Apr 30, 2018
nicolas-grekas added a commit that referenced this pull requestApr 30, 2018
… missing parent class (weaverryan)This PR was merged into the 3.4 branch.Discussion----------ResolveBindingsPass: Don't throw error for unused service, missing parent class| Q             | A| ------------- | ---| Branch?       | 3.4| Bug fix?      | yes| New feature?  | no| BC breaks?    | no| Deprecations? | no->| Tests pass?   | yes| Fixed tickets |symfony/flex#346 (comment)| License       | MIT| Doc PR        | n/aHey guys!In short: if you:A) auto-register a class as a serviceB) That class's parent class is missingC) ... but this class/service is unusedCurrently, `ResolveBindingsPass` will fail and throw an exception. The change avoids that - only throwing the exception if the service IS used. This is already done in `AutowirePass`.The real issue is DoctrineFixturesBundle, where, on production, the bundle (and so, `Fixtures` base class) is not installed, causing a build error, even though these service classes are unused.Cheers!Commits-------309da92 Avoiding an error when an unused service has a missing base class
@weaverryanweaverryan deleted the resolve-bindings-no-error branchApril 30, 2018 12:56
This was referencedApr 30, 2018
@jeroendesloovere
Copy link

Is there any solution out there?
I've posted my environment over heresymfony/flex#346 (comment)

@nicolas-grekas
Copy link
Member

@jeroendesloovere looks totally unrelated... If you found a bug, please open a separate issue.

@jeroendesloovere
Copy link

Are you sure?
I havesrc/DataFixtures/* classes which inherit from DoctrineFixturesBundle which is only loaded in intest anddev environments.

So when I try to deploy to Heroku (which usesprod environment), these DoctrineFixturesBundle classes can't be autoloaded and so everything throws an error.

//...use Doctrine\Bundle\FixturesBundle\Fixture;use Doctrine\Common\DataFixtures\OrderedFixtureInterface;use Doctrine\Common\Persistence\ObjectManager;class LoadUserData extends Fixture implements OrderedFixtureInterface{    public function load(ObjectManager $manager)    {        // ...    }    public function getOrder()    {        return 10;    }}

$calls[] =array($constructor,$value->getArguments());
}
}catch (RuntimeException$e) {
$this->container->getDefinition($this->currentId)->addError($e->getMessage());
Copy link
Member

Choose a reason for hiding this comment

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

should be$value->addError(), no ?

Choose a reason for hiding this comment

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

this could be an inline definition, but we want the main definition to hold the error

@jeroendesloovere
Copy link

jeroendesloovere commentedJul 6, 2018
edited
Loading

Solution

Usingcomposer require doctrine-fixtures-bundle --dev was so wrong.
This has to becomposer require doctrine-fixtures-bundle.

Since in my case, this bundle is used intests.

Wrongcomposer.json

"require":{// ...},"require-dev":{// ..."doctrine/doctrine-fixtures-bundle":"^3.0",},

Correctcomposer.json

"require":{// ..."doctrine/doctrine-fixtures-bundle":"^3.0",},"require-dev":{// ...},

Other things I tried but failed

# services.yamlservices:# ignore datafixtures in production environment,# because it usages DoctrineFixturesBundle classes which are only loaded in for "dev" and "test"  environmentsBabyGuesser\DataFixtures\:resource:'../src/DataFixtures/*'autowire:falseautoconfigure:falsepublic:false

Local everything is perfect, but when pushing to heroku thecache:clear failed every time.

Offout reacted with thumbs up emojijeroendesloovere reacted with hooray emoji

@maximejosien
Copy link

Hello guys,

I had the same error with the DoctrineFixtureBundle, to fix this problem, I added this in my service.yaml

services:    App\:        resource: '../src/*'        exclude: '../src/{DependencyInjection,Entity,Migrations,Tests,DataFixtures,Kernel.php}'

The DateFixtures directory is exclude and I don't have any more this error using prod with this bundle in my composer-dev.

I hope it will help someone.

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

@stofstofstof left review comments

Assignees

No one assigned

Projects

None yet

Milestone

3.4

Development

Successfully merging this pull request may close these issues.

6 participants

@weaverryan@nicolas-grekas@jeroendesloovere@maximejosien@stof@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp