Skip to content

[DependencyInjection] Fix service autowiring inheritance #19643

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

Merged
merged 1 commit into from
Aug 19, 2016

Conversation

chalasr
Copy link
Member

@chalasr chalasr commented Aug 16, 2016

Q A
Branch? 2.8
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #19615
License MIT
Doc PR n/a

This makes services inherit the autowire attribute from their parent and fix the ability to override it from the child.

Fixed cases:

  • Simple inheritance
parent:
    class: Foo
    abstract: true
    autowire: true

child:
    class: Foo
  • Set in the child (only)
parent:
    class: Foo
    abstract: true

child:
    class: Foo
    autowire: true
  • Set in the parent, changed in the child
parent:
    class: Foo
    abstract: true
    autowire: true

child:
    class: Foo
    autowire: false

@dunglas
Copy link
Member

dunglas commented Aug 16, 2016

👍

@weaverryan
Copy link
Member

There's technically a minor BC break: a service whose parent is autowired, would not have been autowired before, but now it would be. But, except for an optional dependency in the constructor, instantiation of that child would have failed, because it would be missing its autowired dependencies. So, the BC break is for child services that have optional, type-hinted constructor args: the container will now try to autowire those, but it didn't before.

Still, this is a bug and that's seems like a real edge-case. I think we should fix it.

If I'm right, should be update the CHANGELOG or UPGRADE doc?

👍

@chalasr chalasr force-pushed the dic_fix_autowire_inherit branch from 22fd618 to 143c5c1 Compare August 17, 2016 02:12
@chalasr
Copy link
Member Author

chalasr commented Aug 17, 2016

CHANGELOG updated, thanks @weaverryan.

@chalasr chalasr force-pushed the dic_fix_autowire_inherit branch from 143c5c1 to 04ce15d Compare August 17, 2016 02:25
@jakzal
Copy link
Contributor

jakzal commented Aug 18, 2016

👍

Although i wouldn't treat it as a BC break. Technically it should either be a bugfix or a BC break :)

@chalasr
Copy link
Member Author

chalasr commented Aug 18, 2016

@jakzal Let me know if I can do something for that.
For now this is described as a bugfix but referenced as a BC break in the DI's changelog.

2.8.9
-----

* [BC BREAK] fixed inheritance of the `autowire` flag
Copy link
Member

Choose a reason for hiding this comment

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

Like @jakzal, I think it's more a bug than a a BC break. Anyway, we should either remove the [BC BREAK] here or merge this PR on master.

Copy link
Member Author

Choose a reason for hiding this comment

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

The BC break flag has been removed as you and @jakzal seem to agree for treat it as a bug fix only.

@chalasr chalasr force-pushed the dic_fix_autowire_inherit branch from 04ce15d to c49f056 Compare August 19, 2016 15:09
-----

* fixed inheritance of the `autowire` flag

Copy link
Member

Choose a reason for hiding this comment

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

The whole paragraph should be removed as the CHANGELOG is automatically generated.

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@chalasr chalasr force-pushed the dic_fix_autowire_inherit branch from c49f056 to fb95bdc Compare August 19, 2016 15:56
@fabpot
Copy link
Member

fabpot commented Aug 19, 2016

Thank you @chalasr.

@fabpot fabpot merged commit fb95bdc into symfony:2.8 Aug 19, 2016
fabpot added a commit that referenced this pull request Aug 19, 2016
…chalasr)

This PR was merged into the 2.8 branch.

Discussion
----------

[DependencyInjection] Fix service autowiring inheritance

| Q             | A
| ------------- | ---
| Branch?       | 2.8
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #19615
| License       | MIT
| Doc PR        | n/a

This makes services inherit the `autowire` attribute from their parent and fix the ability to override it from the child.

Fixed cases:

- Simple inheritance
```yaml
parent:
    class: Foo
    abstract: true
    autowire: true

child:
    class: Foo
```

- Set in the child (only)
```yaml
parent:
    class: Foo
    abstract: true

child:
    class: Foo
    autowire: true
```

- Set in the parent, changed in the child
```yaml
parent:
    class: Foo
    abstract: true
    autowire: true

child:
    class: Foo
    autowire: false
```

Commits
-------

fb95bdc [DIC] Fix service autowiring inheritance
@chalasr chalasr deleted the dic_fix_autowire_inherit branch August 19, 2016 16:31
This was referenced Sep 2, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants