Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[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
Uh oh!
There was an error while loading.Please reload this page.
Conversation
9c1312e to8efecd1Compare
xabbuh left a comment
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.
👍
aschempp commentedMay 17, 2017
This would be inconsistent with the |
ro0NL commentedMay 17, 2017
yes - but we dont care :) if you want consistency use the method as extension hook for both. |
chalasr commentedMay 17, 2017
Yes it's inconsistent, but allows for better maintainability and user experience at the end. There is a lot |
ogizanagi commentedMay 17, 2017 • 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.
Is it really required consideringit's already computed once using |
chalasr commentedMay 17, 2017
@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. |
jvasseur commentedMay 17, 2017
@ogizanagi you could add a method in your kernel that modifies the return value of |
aschempp commentedMay 17, 2017 • 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.
That is exactly the point. Originally, we had a |
aschempp commentedMay 17, 2017
If this is to be merged, the method must not be called on the constructor, otherwise calling the method in |
ro0NL commentedMay 17, 2017 • 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.
Agree; not sure what's the lazy initialization is about. But it doesnt harm really :) |
chalasr commentedMay 17, 2017
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. |
ogizanagi commentedMay 17, 2017
Changing this value after initialization looks weird to me honestly, so I don't really get the point, but ¯\_(ツ)_/¯. |
chalasr commentedMay 17, 2017 • 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.
Not only the value itself, but some other properties on which the custom |
ogizanagi commentedMay 17, 2017
@chalasr: What about removing the the assignationon this line in this PR too, as discussed (as it's already done in the |
| $kernel->boot(); | ||
| $r =new \ReflectionMethod($kernel,'getKernelParameters'); | ||
| $r->setAccessible(true); |
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.
You're cheating ;-)
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.
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 commentedMay 17, 2017
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 commentedMay 17, 2017
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(), |
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.
Should we use the getter variant for other params too, while at it?
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.
Yea I think, I'll do it separately for lower branches once this merged
f9c5705 to234361eComparechalasr commentedMay 18, 2017
constructor assignment removed, changed the test to better show what this prevents. |
xabbuh commentedMay 22, 2017
ping @symfony/deciders |
Tobion commentedMay 22, 2017
👍 |
fabpot commentedMay 25, 2017
Thank you@chalasr. |
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
Uh oh!
There was an error while loading.Please reload this page.
Alternative to#22727 that makes use of the existing public api.