Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[HttpKernel] Deprecate the Kernel name #28809

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
Oct 15, 2018
Merged

Conversation

fabpot
Copy link
Member

@fabpot fabpot commented Oct 10, 2018

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

@@ -421,7 +428,7 @@ protected function build(ContainerBuilder $container)
*/
protected function getContainerClass()
{
return $this->name.ucfirst($this->environment).($this->debug ? 'Debug' : '').'ProjectContainer';
return 'app'.ucfirst($this->environment).($this->debug ? 'Debug' : '').'ProjectContainer';
Copy link
Member

Choose a reason for hiding this comment

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

shouldn't we keep using it for now, for BC ? Otherwise, it would be a BC break for people using multiple kernels (with different names) and expecting to have the container classes not clashing together.

Copy link
Member Author

Choose a reason for hiding this comment

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

You mean when a multi-kernel app share the same cache?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think this is worth it. As of Symfony 4.x, we are only supporting Flex (so, doing it in 3.4 was not possible, but I think this is totally legitimate now).

Copy link
Member Author

Choose a reason for hiding this comment

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

ok, is it better now?

@fabpot fabpot force-pushed the kernel-name branch 3 times, most recently from ce81b5b to 59048e2 Compare October 10, 2018 16:20
@@ -421,7 +428,7 @@ protected function build(ContainerBuilder $container)
*/
protected function getContainerClass()
{
return $this->name.ucfirst($this->environment).($this->debug ? 'Debug' : '').'ProjectContainer';
return 'app'.md5(get_class($this)).ucfirst($this->environment).($this->debug ? 'Debug' : '').'ProjectContainer';
Copy link
Member

Choose a reason for hiding this comment

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

Could this potentially break existing applications with multiple kernels?

Copy link
Member Author

Choose a reason for hiding this comment

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

How? Each Kernel class must have a different FQCN anyway, so it's still unique.

Copy link
Member

Choose a reason for hiding this comment

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

Having additional arguments in the application kernel class that are different for each instance does work too, doesn't it?

Copy link
Member Author

Choose a reason for hiding this comment

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

It can work, but this won't break with my change as in this case, the cache cannot be shared between apps (today already).

Copy link
Member

Choose a reason for hiding this comment

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

This will break apps rely on the kernel name to create "virtual" kernels. For example, I've some projects based on this idea https://github.com/yceruto/symfony-skeleton-vkernel.

I don't know whether this practice is right or not, but it simplify our projects sharing vendors, config and src. It work well thank to the kernel name and just one Kernel class.

Copy link
Member Author

Choose a reason for hiding this comment

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

Then, you need to override the getContainerClass().

@xabbuh
Copy link
Member

xabbuh commented Oct 13, 2018

tests are failing

@nicolas-grekas nicolas-grekas added this to the next milestone Oct 14, 2018
@fabpot
Copy link
Member Author

fabpot commented Oct 15, 2018

Tests fixed

@fabpot fabpot merged commit 98ff750 into symfony:master Oct 15, 2018
fabpot added a commit that referenced this pull request Oct 15, 2018
This PR was merged into the 4.2-dev branch.

Discussion
----------

[HttpKernel] Deprecate the Kernel name

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no     <!-- see https://symfony.com/bc -->
| Deprecations? | yes <!-- don't forget to update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->
| Fixed tickets | #26904
| License       | MIT
| Doc PR        | n/a

<!--
Write a short README entry for your feature/bugfix here (replace this comment block.)
This will help people understand your PR and can be used as a start of the Doc PR.
Additionally:
 - Bug fixes must be submitted against the lowest branch where they apply
   (lowest branches are regularly merged to upper ones so they get the fixes too).
 - Features and deprecations must be submitted against the master branch.
-->

Commits
-------

98ff750 [HttpKernel] deprecated the Kernel name
@@ -421,7 +428,7 @@ protected function build(ContainerBuilder $container)
*/
protected function getContainerClass()
{
return $this->name.ucfirst($this->environment).($this->debug ? 'Debug' : '').'ProjectContainer';
return str_replace('\\', '_', \get_class($this)).ucfirst($this->environment).($this->debug ? 'Debug' : '').'Container';
Copy link
Member

@nicolas-grekas nicolas-grekas Oct 16, 2018

Choose a reason for hiding this comment

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

This change breaks BC by removing the "name" (the basename of the project_dir really) from the dimensions that compose separate namespaces.
This is why the CI is red (and was also caught before merging ;) )
Side note: the container class is also a legacy concept; its real name is random (it's the hash of its contents actually.)
The only real remaining use case of the container class is for generating the name of the file that serves as entry point for loading the container.

fabpot added a commit that referenced this pull request Oct 16, 2018
This PR was merged into the 4.2-dev branch.

Discussion
----------

[HttpKernel] fix kernel.name deprecation

| Q             | A
| ------------- | ---
| Branch?       | 4.2
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

Finishes #28809 and makes tests green again.

Commits
-------

4964ffc [HttpKernel] fix kernel.name deprecation
nicolas-grekas added a commit that referenced this pull request Oct 23, 2018
This PR was squashed before being merged into the 4.2-dev branch (closes #28939).

Discussion
----------

[WebProfilerBundle] Remove application name

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | yes
| New feature?  | yes
| BC breaks?    | no     <!-- see https://symfony.com/bc -->
| Deprecations? | yes
| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->
| Fixed tickets | #...   <!-- #-prefixed issue number(s), if any -->
| License       | MIT
| Doc PR        | symfony/symfony-docs#... <!-- required for new features -->

This fixes a regression in master, i think after #28809 (or something related)

There's still a "application name" concept out there today, and it's `ConfigDataCollector::getApplicationName()` 🤔

In my case the service resolved to

```php
$e = new \Symfony\Component\HttpKernel\DataCollector\ConfigDataCollector(\basename('/app'));
```

Causing the app name to be, well, `app` (again :P). It was really confusing.

Before:

![image](https://user-images.githubusercontent.com/1047696/47264761-fcb01980-d51c-11e8-9a3b-14a43d18b179.png)

(the "a" is from "app" here)

After:

![image](https://user-images.githubusercontent.com/1047696/47264767-16516100-d51d-11e8-8a5d-4c20d4911861.png)

or

![image](https://user-images.githubusercontent.com/1047696/47264774-28cb9a80-d51d-11e8-8fe6-de0f46b06a1d.png)

I think we need to deprecate the argument for real?

cc @fabpot

Commits
-------

f5c355e [WebProfilerBundle] Remove application name
@nicolas-grekas nicolas-grekas modified the milestones: next, 4.2 Nov 1, 2018
This was referenced Nov 3, 2018
@fabpot fabpot deleted the kernel-name branch January 14, 2019 11:01
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.

9 participants