Skip to content

[HttpKernel] fix kernel.name deprecation #28888

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 16, 2018
Merged

Conversation

nicolas-grekas
Copy link
Member

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.

@@ -367,7 +367,7 @@ protected function loadCacheDriver($cacheName, $objectManagerName, array $cacheD
} else {
$seed = '_'.$container->getParameter('kernel.project_dir');
}
$seed .= '.'.$container->getParameter('kernel.container_class').'.'.$container->getParameter('kernel.environment').'.'.$container->getParameter('kernel.debug');
$seed .= '.'.$container->getParameter('kernel.container_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.

kernel.container_class already embeds the entropy from kernel.environment and kernel.debug

@@ -276,6 +276,8 @@ public function locateResource($name, $dir = null, $first = true)

/**
* {@inheritdoc}
*
* @deprecated since Symfony 4.2
Copy link
Member Author

Choose a reason for hiding this comment

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

let's be even more explicit and duplicate this info from the interface

return str_replace('\\', '_', \get_class($this)).ucfirst($this->environment).($this->debug ? 'Debug' : '').'Container';
$name = \get_class($this);
if (false !== $i = strrpos($name, '\\')) {
$name = substr($name, 1 + $i);
Copy link
Member Author

Choose a reason for hiding this comment

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

keeping only the last part is enough IMHO

Copy link
Member

Choose a reason for hiding this comment

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

I would say quite the contrary for multi-app projects. Let's stay on the safe side and keep the FQDN.

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, reverted

$name = substr($name, 1 + $i);
}

return $this->name.$name.ucfirst($this->environment).($this->debug ? 'Debug' : '').'Container';
Copy link
Member Author

Choose a reason for hiding this comment

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

adding $this->name back is what fixes deps=high tests - to be removed in 5.0 (alongside with the property)

$name = substr($name, 1 + $i);
}

return $this->name.$name.ucfirst($this->environment).($this->debug ? 'Debug' : '').'Container';
Copy link
Member

Choose a reason for hiding this comment

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

This change is wrong. We don't want to rely on the name anymore. Right now, name is kind of required only because of the way we tests things internally, but nobody will have the same issue IRL.

Copy link
Member Author

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

what's the issue with keeping it in 4.x and removing in 5.0?
Patching tests on lower branches looks even more wrong to me

@@ -440,7 +442,7 @@ protected function build(ContainerBuilder $container)
*/
protected function getContainerClass()
{
return str_replace('\\', '_', \get_class($this)).ucfirst($this->environment).($this->debug ? 'Debug' : '').'Container';
return $this->name.str_replace('\\', '_', \get_class($this)).ucfirst($this->environment).($this->debug ? 'Debug' : '').'Container';
Copy link
Member Author

Choose a reason for hiding this comment

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

Keeping the $this->name prefix is a requirement here. The failing tests on lower branches hint this is a BC break for multi-kernel apps that generate a different container per name.
Once ppl will have moved out of using name, then we will be free to remove it - in 5.0.

@fabpot
Copy link
Member

fabpot commented Oct 16, 2018

Thank you @nicolas-grekas.

@fabpot fabpot merged commit 4964ffc into symfony:master Oct 16, 2018
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 nicolas-grekas deleted the kname branch October 16, 2018 13:38
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.

3 participants