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

[HttpKernel] Fix kernel.project_dir extensibility#22728

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
fabpot merged 1 commit intosymfony:3.3fromchalasr:get-proj-dir
May 25, 2017

Conversation

@chalasr
Copy link
Member

@chalasrchalasr commentedMay 17, 2017
edited
Loading

QA
Branch?3.3
Bug fix?yes
New feature?no
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets#22727
LicenseMIT
Doc PRn/a

Alternative to#22727 that makes use of the existing public api.

linaori, ro0NL, and jvasseur reacted with thumbs up emoji
Copy link
Member

@xabbuhxabbuh left a comment

Choose a reason for hiding this comment

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

👍

@aschempp
Copy link
Contributor

This would be inconsistent with therootDir imho?

@ro0NL
Copy link
Contributor

yes - but we dont care :)

if you want consistency use the method as extension hook for both.

@chalasr
Copy link
MemberAuthor

Yes it's inconsistent, but allows for better maintainability and user experience at the end. There is a lotprotected members in the core codebase, but since a long time, we do not introduce new ones without a strong reason, and we even made some private afterwards (generally through "opportunity").
Also,getProjectDir() makesrootDir obsolete, we should remove it on the long run, no need for changing this now.

ro0NL reacted with thumbs up emoji

@ogizanagi
Copy link
Contributor

ogizanagi commentedMay 17, 2017
edited
Loading

@chalasr
Copy link
MemberAuthor

@ogizanagi is right, but I think it's better to always call the method. If the constructor behavior changes a day, and given the method itself return the property if initialized, I think it's sane to use it rather than the prop.

ro0NL reacted with thumbs up emoji

@jvasseur
Copy link
Contributor

@ogizanagi you could add a method in your kernel that modifies the return value ofgetProjectDir between the moment the object is created and the moment the container is compiled.

@aschempp
Copy link
Contributor

aschempp commentedMay 17, 2017
edited
Loading

you could add a method in your kernel that modifies the return value of getProjectDir between the moment the object is created and the moment the container is compiled.

That is exactly the point. Originally, we had asetRootDir method to tell the Kernel where it's root dir is located. Because our kernel is distributed with a bundle but the root dir is still/app. Now that does no longer work withprojectDir, as we cannot override it after__construct (even thoughgetKernelParameters has not been called yet).

@aschempp
Copy link
Contributor

If this is to be merged, the method must not be called on the constructor, otherwise calling the method ingetKernelParameters does not make much sense to me.

@ro0NL
Copy link
Contributor

ro0NL commentedMay 17, 2017
edited
Loading

Agree; not sure what's the lazy initialization is about. But it doesnt harm really :)

@chalasr
Copy link
MemberAuthor

otherwise calling the method in getKernelParameters does not make much sense to me.

I don't think so. The getter is the extension point. The private property is set at construction so that it is always available internally; and the method is called when needed. As pointed by@jvasseur, the kernel state can change after construction, always calling the method is just safe-guard, that's fine to me.

ro0NL reacted with thumbs up emoji

@ogizanagi
Copy link
Contributor

you could add a method in your kernel that modifies the return value of getProjectDir between the moment the object is created and the moment the container is compiled.

the kernel state can change after construction

Changing this value after initialization looks weird to me honestly, so I don't really get the point, but ¯\_(ツ)_/¯.

@chalasr
Copy link
MemberAuthor

chalasr commentedMay 17, 2017
edited
Loading

Not only the value itself, but some other properties on which the customgetProjectRootdir() could rely on... it's all about weird edge cases, but preventing them in the parent class doesn't harm, and since we can do it easily...

@ogizanagi
Copy link
Contributor

@chalasr: What about removing the the assignationon this line in this PR too, as discussed (as it's already done in theKernel::getProjectDir() implementation) ?

$kernel->boot();

$r =new \ReflectionMethod($kernel,'getKernelParameters');
$r->setAccessible(true);
Copy link
Contributor

Choose a reason for hiding this comment

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

You're cheating ;-)

Copy link
Contributor

@ro0NLro0NLMay 17, 2017
edited
Loading

Choose a reason for hiding this comment

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

Besides due the constructor initialization this test also passes without your change :) so we actually need to test some weird edge case here. Perhaps return different values on consecutive calls?

@aschempp
Copy link
Contributor

The private property is set at construction so that it is always available internally; and the method is called when needed.

The property must not be used internally (except for the getter method) if the getter is to be the extension point! So there's no point in initializing it.

@ro0NL
Copy link
Contributor

Tend to agree with that :) it also makes the test valid.

array(
'kernel.root_dir' =>realpath($this->rootDir) ?:$this->rootDir,
'kernel.project_dir' =>realpath($this->projectDir) ?:$this->projectDir,
'kernel.project_dir' =>realpath($this->getProjectDir()) ?:$this->getProjectDir(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we use the getter variant for other params too, while at it?

aschempp reacted with thumbs up emoji
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Yea I think, I'll do it separately for lower branches once this merged

ro0NL reacted with thumbs up emoji
@chalasrchalasrforce-pushed theget-proj-dir branch 3 times, most recently fromf9c5705 to234361eCompareMay 18, 2017 08:55
@chalasr
Copy link
MemberAuthor

constructor assignment removed, changed the test to better show what this prevents.

ogizanagi, ro0NL, aschempp, and ausi reacted with thumbs up emoji

@chalasrchalasr changed the base branch frommaster to3.3May 18, 2017 09:29
@nicolas-grekasnicolas-grekas added this to the3.3 milestoneMay 18, 2017
@xabbuh
Copy link
Member

ping @symfony/deciders

@Tobion
Copy link
Contributor

👍

@fabpot
Copy link
Member

Thank you@chalasr.

@fabpotfabpot merged commit3230fc7 intosymfony:3.3May 25, 2017
fabpot added a commit that referenced this pull requestMay 25, 2017
This PR was merged into the 3.3 branch.Discussion----------[HttpKernel] Fix kernel.project_dir extensibility| Q             | A| ------------- | ---| Branch?       | 3.3| Bug fix?      | yes| New feature?  | no| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets |#22727| License       | MIT| Doc PR        | n/aAlternative to#22727 that makes use of the existing public api.Commits-------3230fc7 Fix kernel.project_dir extensibility
@chalasrchalasr deleted the get-proj-dir branchMay 26, 2017 01:57
@fabpotfabpot mentioned this pull requestMay 29, 2017
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@xabbuhxabbuhxabbuh approved these changes

+3 more reviewers

@ro0NLro0NLro0NL left review comments

@aschemppaschemppaschempp approved these changes

@leofeyerleofeyerleofeyer approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

3.3

Development

Successfully merging this pull request may close these issues.

11 participants

@chalasr@aschempp@ro0NL@ogizanagi@jvasseur@xabbuh@Tobion@fabpot@leofeyer@nicolas-grekas@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp