Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[DI] Initialize properties before method calls#20566
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
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Tobion commentedNov 19, 2016
The change makes sense to me. |
linaori commentedNov 19, 2016
Isn't this a case where a configurator would make more sense? (though I agree with the fix) |
ro0NL commentedNov 19, 2016 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
It's really simple (property) "configuration" (only initializing) :) i'd prefer this approach working out-of-the-box instead of setting up a configurator class, etc. |
fabpot commentedNov 22, 2016
Tests are broken (the dumped containers should be updated). |
ro0NL commentedNov 22, 2016
@fabpot green (ignore fabbot.io) |
fabpot commentedNov 24, 2016
Now, the question is wether we need to merge this in 2.7 or 3.2. I would vote for 3.2. |
xabbuh commentedNov 24, 2016
To me, this looks like a bugfix and should be merged into 2.7. Merging this into 3.2 also has the drawback that the behaviour does change between supported versions which might be needless additional work for maintainers who need this feature for 2.x and 3.x. |
nicolas-grekas commentedNov 24, 2016
Would it be possible to have a test case that shows why this ordering is important? The fixture update doesn't qualify as such to me (too easy to update them without considering the actual side effect). |
nicolas-grekas commentedNov 24, 2016
Ping @symfony/deciders , we need to make a decision on this one before the end of the week for 3.2 to be ready (1/3). |
xabbuh commentedNov 24, 2016
👍 for merging this into 2.7 and if possible in any way with a test like suggested by@nicolas-grekas |
ro0NL commentedNov 24, 2016
Ill add the test somewhere tonight 👍 this is about asserting a property is initialized within a method call right? |
stof commentedNov 24, 2016
@ro0NL yes |
| $this->assertTrue($classInList); | ||
| } | ||
| publicfunctiontestInitialziePropertiesBeforeMethodCalls() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
typo: Initialize
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
The approach is OK though?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
looks good yes
ro0NL commentedNov 24, 2016
Test added.. however it does not involve the |
ro0NL commentedNov 24, 2016
Let's be safe :) Speaking about.. what kind of case could we break in real life apps on 2.7? As it's only affected during serviceinitialization. Imo. it qualifies a bugfix. |
Tobion commentedNov 25, 2016
Considering the impact of bug fixes like#20562, it might be safer to change the behavior only in 3.2. But I'm fine either way. |
nicolas-grekas commentedNov 25, 2016
I have the same kind of thought than@Tobion . Yet,if this happens to break something, breaking 3.2 is not better than breaking 2.7. For this reason, and also because I fail to see where this can break anything reasonable, I'm 👍 for 2.7. |
stof commentedNov 25, 2016
The only case we could break is when you have a method call changing behavior when the property is initialized or no, and initializing the property as a public property. This case looks quite insane though (and if the initialization relies on this to be working, the class is quite unusable directly). So I'm also 👍 for 2.7 as it allows methods to rely on the property values. |
nicolas-grekas commentedNov 25, 2016
Good catch, thanks@ro0NL. |
This PR was squashed before being merged into the 2.7 branch (closes#20566).Discussion----------[DI] Initialize properties before method calls| Q | A| ------------- | ---| Branch? | 2.7| Bug fix? | yes-ish| New feature? | no| BC breaks? | not sure| Deprecations? | no| Tests pass? | not yet (only dumps seem to fail)| Fixed tickets | comma-separated list of tickets fixed by the PR, if any| License | MIT| Doc PR | reference to the documentation PR, if anyGiven```ymlservices: handler: class: AppBundle\Handler properties: debug: '%kernel.debug%' calls: - [handle]```I totally expected `Handler::$debug` to be set before `Handler::handle` is called. It was not.. and it's really annoying :)Commits-------0af433b [DI] Initialize properties before method calls
fabpot commentedNov 25, 2016
That's yet again a very wrong argument: making such a change in 2.7.x is very different from making the change in 2.x. Also because we can document the change in the UPGRADE file. I would not have merged it in 2.7 for that reason. We are doing too much of these, we should stop. We had problems in the past and it looks like we are not learning from them. |
nicolas-grekas commentedNov 25, 2016
May I add that it's not much better to break 2/3.x than it is to break 2.7.x. What I mean is than when we change a behavior, we must force ourselves to find a way to first deprecate the old one. Thus, this will naturally make such PRs move to master (or be rejected). Learning from past mistakes here IMHO means being stricter to what we consider a behavioral change and what we don't (not arguing about this specific PR thought.) |
fabpot commentedNov 25, 2016
There is of course a big difference between "breaking" x.y.z and breaking x.y. |
linaori commentedNov 25, 2016 via email
To be fair, this sounds like a behavioural change more than a bug fix. …On Fri, 25 Nov 2016, 23:01 Fabien Potencier, ***@***.***> wrote: There is of course a big difference between "breaking" x.y.z and breaking x.y. — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#20566 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/ABrGNs_87LEdmzjHjx2A4uRga0N3Zb8Mks5rB1q8gaJpZM4K3Ozg> . |
ro0NL commentedNov 26, 2016
Imo. having different behavior cross-version should be avoided as much as possible. I still think the impact minimal, as@stof mentioned.. people are doing really weird things then (if they notice at all). However, there are also things like EOM/EOL.... And the line is really thin here.. yes it's a behavior change, yet pragmatically, it qualifies a bugfix (imo) but technically it's a new feature for sure. |
Uh oh!
There was an error while loading.Please reload this page.
Given
I totally expected
Handler::$debugto be set beforeHandler::handleis called. It was not.. and it's really annoying :)