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

[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

Closed
ro0NL wants to merge3 commits intosymfony:2.7fromro0NL:di/props-before-calls
Closed

[DI] Initialize properties before method calls#20566

ro0NL wants to merge3 commits intosymfony:2.7fromro0NL:di/props-before-calls

Conversation

@ro0NL
Copy link
Contributor

@ro0NLro0NL commentedNov 19, 2016
edited
Loading

QA
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 ticketscomma-separated list of tickets fixed by the PR, if any
LicenseMIT
Doc PRreference to the documentation PR, if any

Given

services:handler:class:AppBundle\Handlerproperties:debug:'%kernel.debug%'calls:            -[handle]

I totally expectedHandler::$debug to be set beforeHandler::handle is called. It was not.. and it's really annoying :)

ogizanagi, chalasr, hason, yceruto, and theofidry reacted with thumbs up emoji
@Tobion
Copy link
Contributor

The change makes sense to me.

jean-pasqualini reacted with thumbs up emoji

@linaori
Copy link
Contributor

Isn't this a case where a configurator would make more sense? (though I agree with the fix)

@ro0NL
Copy link
ContributorAuthor

ro0NL commentedNov 19, 2016
edited
Loading

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.

@ro0NLro0NL changed the base branch frommaster to2.7November 20, 2016 09:01
@fabpot
Copy link
Member

Tests are broken (the dumped containers should be updated).

@ro0NL
Copy link
ContributorAuthor

@fabpot green (ignore fabbot.io)

@fabpot
Copy link
Member

Now, the question is wether we need to merge this in 2.7 or 3.2. I would vote for 3.2.

@fabpotfabpot added this to the3.2 milestoneNov 24, 2016
@xabbuh
Copy link
Member

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.

ro0NL, hason, and nicolas-grekas reacted with thumbs up emoji

@nicolas-grekas
Copy link
Member

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).

ro0NL reacted with thumbs up emoji

@nicolas-grekas
Copy link
Member

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
Copy link
Member

👍 for merging this into 2.7 and if possible in any way with a test like suggested by@nicolas-grekas

@ro0NL
Copy link
ContributorAuthor

Ill add the test somewhere tonight 👍 this is about asserting a property is initialized within a method call right?

@nicolas-grekasnicolas-grekas modified the milestone:3.2Nov 24, 2016
@stof
Copy link
Member

@ro0NL yes

$this->assertTrue($classInList);
}

publicfunctiontestInitialziePropertiesBeforeMethodCalls()

Choose a reason for hiding this comment

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

typo: Initialize

Copy link
ContributorAuthor

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?

Choose a reason for hiding this comment

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

looks good yes

@ro0NL
Copy link
ContributorAuthor

Test added.. however it does not involve thePhpDumper i realize now :) It covers onlyContainerBuilder 🤔 Should we add a similar test there as well?

@ro0NL
Copy link
ContributorAuthor

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
Copy link
Contributor

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
Copy link
Member

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
Copy link
Member

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
Copy link
Member

Good catch, thanks@ro0NL.

nicolas-grekas added a commit that referenced this pull requestNov 25, 2016
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
@ro0NLro0NL deleted the di/props-before-calls branchNovember 25, 2016 09:50
@fabpot
Copy link
Member

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
Copy link
Member

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
Copy link
Member

There is of course a big difference between "breaking" x.y.z and breaking x.y.

@linaori
Copy link
Contributor

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
Copy link
ContributorAuthor

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.

@fabpotfabpot mentioned this pull requestNov 27, 2016
This was referencedDec 13, 2016
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@nicolas-grekasnicolas-grekasnicolas-grekas left review comments

Assignees

No one assigned

Projects

None yet

Milestone

3.2

Development

Successfully merging this pull request may close these issues.

8 participants

@ro0NL@Tobion@linaori@fabpot@xabbuh@nicolas-grekas@stof@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp