Skip to content

Unexpected deprecation message related to an entity #24569

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

Closed
javiereguiluz opened this issue Oct 16, 2017 · 10 comments
Closed

Unexpected deprecation message related to an entity #24569

javiereguiluz opened this issue Oct 16, 2017 · 10 comments

Comments

@javiereguiluz
Copy link
Member

Q A
Bug report? yes
Feature request? no
BC Break report? no
RFC? no
Symfony version 3.4

We're updating the Symfony Demo application to Symfony 3.4 (see symfony/demo#673). Most of the triggered deprecations make sense, but we're struggling with this one:

entity-deprecation

Why does that deprecation occur? We even exclude the entire Entity/ directory from autowiring:

    App\:
        resource: '../src/*'
        exclude: '../src/{DataFixtures,Entity,Repository,Tests}'
@linaori
Copy link
Contributor

linaori commented Oct 16, 2017

Hmm would be nice if the deprecation would tell us which code is triggering this edge-case.

Side note, the deprecation could be optimized by passing $type only once by using %1$s twice.

@stof
Copy link
Member

stof commented Oct 16, 2017

@javiereguiluz I think this is related to the autowiring of controller arguments (where you might have a typehint for a Post relying on param converters). As there is no autowirable service for this typehint, the AutowirePass triggers the BC layer to try finding one such service by type.

@javiereguiluz
Copy link
Member Author

@stof you are right! We use Post as a "param converter" in lots of controllers like this one:

public function showAction(Post $post): Response

Could this be considered a bug? We want to use Post as a param converter, not as a service injection.

@linaori
Copy link
Contributor

linaori commented Oct 16, 2017

Pretty much anything could be added as arguments there via the new controller arguments event and argument value resolvers. Besides of this, pretty much anything that's being set in the request object can be injected this way, not sure if you can catch all those cases.

@yceruto
Copy link
Member

yceruto commented Oct 16, 2017

This process is carried out in RegisterControllerArgumentLocatorsPass, is there a way to know all the excluded resources there? could we verify it to omit these cases?

@linaori
Copy link
Contributor

linaori commented Oct 16, 2017

@yceruto no, you can't know this as a lot of things are resolved during run-time execution. You can only know if they are available as service or not.

Edit: This is why I don't like services as action arguments.

@yceruto
Copy link
Member

yceruto commented Oct 16, 2017

So if we have explicit configuration that excludes resources:

App\:
    resource: '../src/*'
    exclude: '../src/{Entity,Repository,Tests}' # <------

we can't use this information into *Pass to avoid auto-registration of controller typed arguments that aren't available as service?

<service id="autowired.App\Entity\Post" class="App\Entity\Post" public="false" autowire="true"/>

this service is defined at compilation-time, so I hope there is some solution for that.

@weaverryan
Copy link
Member

So this is one of the big reasons that we removed the auto-registration of services for autowiring in 4.0. So in 4.0, it’s not an issue - the entities are excluded in services.yml, and then are not auto-registered during autowiring.

But yes, the deprecation warning is a problem - a bug that we need to fix somehow.

@weaverryan weaverryan added the Bug label Oct 16, 2017
@weaverryan weaverryan added this to the 3.4 milestone Oct 16, 2017
@Tobion
Copy link
Contributor

Tobion commented Oct 27, 2017

This is basically fixed with #24671 when enabled, isn't it?

@kbond
Copy link
Member

kbond commented Oct 27, 2017

#24671 solves this problem for me.

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

No branches or pull requests

9 participants