Skip to content
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

[DI] Remove deprecated case insensitive service ids #22811

Closed
wants to merge 2 commits into from
Closed

[DI] Remove deprecated case insensitive service ids #22811

wants to merge 2 commits into from

Conversation

ro0NL
Copy link
Contributor

@ro0NL ro0NL commented May 20, 2017

Q A
Branch? master
Bug fix? no
New feature? no
BC breaks? yes
Deprecations? no
Tests pass? yes
Fixed tickets #...
License MIT
Doc PR symfony/symfony-docs#...

See #21223

4.0.0
-----

* [BC BREAK] removed support for case insensitive service identifiers
Copy link
Member

Choose a reason for hiding this comment

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

BC BREAK prefix not needed

@nicolas-grekas
Copy link
Member

I think we need a proper behavior + test when two services are defined (ie pre-compile, using ContainerBuilder) and they have an id that differs only by the case: either it works properly (does it already?) or fail early (might be more DX friendly?)

@ro0NL
Copy link
Contributor Author

ro0NL commented May 21, 2017

method map seems prepared :)

         $this->methodMap = array(
-            'bar' => 'getBarService',
+            'BAR' => 'getBARService',
+            'BAR2' => 'getBAR2Service',
+            'bar' => 'getBar3Service',
+            'bar2' => 'getBar22Service',

will add one more test for PhpDumper :) but i think it works properly 👍

@@ -30,6 +30,9 @@ digraph sc {
node_lazy_context [label="lazy_context\nLazyContext\n", shape=record, fillcolor="#eeeeee", style="filled"];
node_lazy_context_ignore_invalid_ref [label="lazy_context_ignore_invalid_ref\nLazyContext\n", shape=record, fillcolor="#eeeeee", style="filled"];
node_closure_proxy [label="closure_proxy\nBarClass\n", shape=record, fillcolor="#eeeeee", style="filled"];
node_bar [label="BAR\nstdClass\n", shape=record, fillcolor="#eeeeee", style="filled"];
node_bar2 [label="bar2\nstdClass\n", shape=record, fillcolor="#eeeeee", style="filled"];
node_bar2 [label="BAR2\nstdClass\n", shape=record, fillcolor="#eeeeee", style="filled"];
Copy link
Contributor Author

@ro0NL ro0NL May 21, 2017

Choose a reason for hiding this comment

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

not sure this is actually needs to be lowercased, perhaps qualifies a bugfix (2.7).

edit: or master / this PR; as it's an issue as of now. Let me know.

Copy link
Member

Choose a reason for hiding this comment

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

IMO this needs to be fixed as part of this PR

Copy link
Member

Choose a reason for hiding this comment

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

Graphviz nodes seem to be case-sensitive. so removing the lowercase should fix this.

@ro0NL
Copy link
Contributor Author

ro0NL commented May 21, 2017

@nicolas-grekas geen! new tests are proper imo. and allows for future edge cases to be added. I think we should at least try out this behavior on master =/

Changes to Container.php best reviewed at https://github.com/symfony/symfony/pull/22811/files?w=1#diff-1df5b32be44d0f592ec285c6bbf386bb

fabbot.io failure seems unrelated :)

Ready for review.

@nicolas-grekas
Copy link
Member

rebase needed

@@ -1140,6 +1140,21 @@ public function testRegisterForAutoconfiguration()
// when called multiple times, the same instance is returned
$this->assertSame($childDefA, $container->registerForAutoconfiguration('AInterface'));
}

public function testCaseInsensitivity()
Copy link
Member

Choose a reason for hiding this comment

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

should be testCaseSensitivity

* @expectedDeprecation Service identifiers will be made case sensitive in Symfony 4.0. Using "Foo" instead of "foo" is deprecated since version 3.3.
*/
public function testGetInsensitivity()
public function testCaseInsensitivity()
Copy link
Member

Choose a reason for hiding this comment

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

same

@@ -49,7 +49,7 @@ protected function resetService($name)
}
$manager->setProxyInitializer(\Closure::bind(
function (&$wrappedInstance, LazyLoadingInterface $manager) use ($name) {
if (isset($this->aliases[$name = strtolower($name)])) {
if (isset($this->aliases[$name])) {
$name = $this->aliases[$name];
}
$method = !isset($this->methodMap[$name]) ? 'get'.strtr($name, $this->underscoreMap).'Service' : $this->methodMap[$name];
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@stof not sure here.. it seems forgotten? This is the only use-case of Container::$underscoreMap left.

Copy link
Member

Choose a reason for hiding this comment

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

methodMap will always be filled in 4.0 (we removed support for dumping a container with a custom dumper not dumping the method map)

@ro0NL
Copy link
Contributor Author

ro0NL commented May 26, 2017

should i remove the (deprecated) FactoryReturnTypePass while at it? removing the strtolower calls breaks test :)

cc @GuilhemN

@GuilhemN
Copy link
Contributor

GuilhemN commented May 26, 2017

method map seems prepared :)

#18167 indeed added support for sensitivity while fixing the PhpDumper for non alphanumeric ids.

should i remove the (deprecated) FactoryReturnTypePass while at it?

I think it would be easier to review if it was done in another PR. Nothing would prevent you from merging this PR here though.

@ro0NL
Copy link
Contributor Author

ro0NL commented May 29, 2017

Reverted compiler passes, they need to have a look though :) as well as the Container::$underscoreMap thingy.

Other then that, i think this is ready :)

@@ -49,7 +49,7 @@ protected function resetService($name)
}
$manager->setProxyInitializer(\Closure::bind(
function (&$wrappedInstance, LazyLoadingInterface $manager) use ($name) {
if (isset($this->aliases[$name = strtolower($name)])) {
if (isset($this->aliases[$name])) {
$name = $this->aliases[$name];
}
$method = !isset($this->methodMap[$name]) ? 'get'.strtr($name, $this->underscoreMap).'Service' : $this->methodMap[$name];
Copy link
Member

Choose a reason for hiding this comment

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

methodMap will always be filled in 4.0 (we removed support for dumping a container with a custom dumper not dumping the method map)

@@ -49,7 +49,7 @@ protected function resetService($name)
}
$manager->setProxyInitializer(\Closure::bind(
function (&$wrappedInstance, LazyLoadingInterface $manager) use ($name) {
if (isset($this->aliases[$name = strtolower($name)])) {
Copy link
Member

Choose a reason for hiding this comment

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

this requires a bugfix in 3.3 first instead: we need to use the normalizedIds property here instead of lowercasing (internal storage does not use lowercase anymore)

@fabpot
Copy link
Member

fabpot commented Jul 6, 2017

@ro0NL What's the status of this PR?

@ro0NL
Copy link
Contributor Author

ro0NL commented Jul 6, 2017

@fabpot i should rebase at least :) let me have a look tomorrow evening / saturday.

Status: needs work

@ro0NL
Copy link
Contributor Author

ro0NL commented Jul 7, 2017

@fabpot looks good to me 👍

?w=1

Status: needs review

@@ -28,7 +28,7 @@
*
* Parameter and service keys are case insensitive.
*
* A service id can contain lowercased letters, digits, underscores, and dots.
* A service id can contain letters, digits, underscores, and dots.
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't seem correct anymore. Service ids are not actually validated are they? They can also contain namespace backslashes for example.

Copy link
Contributor

@GuilhemN GuilhemN Jul 7, 2017

Choose a reason for hiding this comment

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

Imo this comment should be removed, a service id can indeed contain any character.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My guess is this was written from a file loader pov, As in fact any character is allowed as of 2.7.

@@ -28,7 +28,7 @@
*
* Parameter and service keys are case insensitive.
Copy link
Member

Choose a reason for hiding this comment

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

this is not up-to-date as well

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

@@ -28,7 +28,7 @@
*
* Parameter and service keys are case insensitive.
*
* A service id can contain lowercased letters, digits, underscores, and dots.
* A service id can contain letters, digits, underscores, and dots.
* Underscores are used to separate words, and dots to group services
Copy link
Member

Choose a reason for hiding this comment

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

this should also mention that this is only relevant when you have several services of the same class. otherwise you can use service id == class name.

Copy link
Contributor Author

@ro0NL ro0NL Jul 8, 2017

Choose a reason for hiding this comment

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

I removed the whole block =/ This is just some service id convention, not really related to the container at all; as it allows any character as mentioned.

The part about creating a method is outdated, as it only checks the method map now.

@nicolas-grekas
Copy link
Member

Thank you @ro0NL.

@ro0NL ro0NL deleted the di/service-ids-4.0 branch July 12, 2017 11:22
fabpot added a commit that referenced this pull request Jul 17, 2017
This PR was merged into the 2.7 branch.

Discussion
----------

[DI] Remove irrelevant comment from container

| Q             | A
| ------------- | ---
| Branch?       | 2.7
| Bug fix?      | yes-ish
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #... <!-- #-prefixed issue number(s), if any -->
| License       | MIT
| Doc PR        | symfony/symfony-docs#... <!--highly recommended for new features-->

Spotted in #22811

Commits
-------

595a225 [DI] Remove irrelevant comment from container
@fabpot fabpot mentioned this pull request Oct 19, 2017
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.

None yet

7 participants