8000 [DI] Removed deprecated setting private/pre-defined services by ro0NL · Pull Request #22801 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[DI] Removed deprecated setting private/pre-defined services #22801

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
Jul 17, 2017
Merged

[DI] Removed deprecated setting private/pre-defined services #22801

merged 1 commit into from
Jul 17, 2017

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 #21533, #19708 and #19146

@nicolas-grekas privates should be excluded from getServiceIds right? i also wondered.. did we forget to deprecate checking privates with initialized()?

@nicolas-grekas
Copy link
Member
nicolas-grekas commented May 20, 2017

privates should be excluded from getServiceIds

right, private are "invisible"

did we forget to deprecate checking privates with initialized

looks like so, we have to do it in 3.4

@nicolas-grekas nicolas-grekas modified the milestone: 4.0 May 20, 2017
@ro0NL
Copy link
Contributor Author
ro0NL commented May 20, 2017

3.3 no? the sooner the better right; given 3.3 is still in RC fase, cant we push it?

@nicolas-grekas
Copy link
Member

3.4 is fine, 3.3 is closed for "features" (deprecations are)

}

if (isset($this->privates[$id])) {
throw new InvalidArgumentException(sprintf('You cannot set the private service "%s".', $id));
Copy link
Contributor Author
@ro0NL ro0NL May 20, 2017

Choose a reason for hiding this comment

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

not sure if this should throw actually? compared to setting a new service (Container::$synthetics?)

thats a bit more work though.. but we have to decide in this PR i guess :)

@nicolas-grekas
Copy link
Member

rebase needed

@xabbuh
Copy link
Member
xabbuh commented May 22, 2017

Can't we merge all your DI related PRs into one big PR that removes all deprecated code paths for that component? That would be easier to review IMO.

@ro0NL
Copy link
Contributor Author
8000 ro0NL commented May 22, 2017

Not sure.. if it's OK i'd like to do it per feature :) prepared the PR's pretty well, and like to test/rebase after each update.

@nicolas-grekas
Copy link
Member

so, you can rebase again

nicolas-grekas added a commit that referenced this pull request May 22, 2017
…ro0NL)

This PR was merged into the 3.4 branch.

Discussion
----------

[DI] Deprecate Container::initialized() for privates

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

See #22801 (comment)

Failing test seems unrelated.

Commits
-------

e0eb247 [DI] Deprecate Container::initialized() for privates
if (isset($this->services[$id])) {
return true;
}

if (isset($this->privates[$id])) {
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 this be moved earlier in 3.x ? If the private service was already instantiated, the code would return true above without triggering the notice

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Think so... will have a look soonish :)

@@ -317,9 +317,6 @@ public function get($id, $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE

return;
}
if (isset($this->privates[$id])) {
Copy link
Member

Choose a reason for hiding this comment

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

Same here, shouldn't it be moved above the check for shared services ? Otherwise, getting an already initialized private service will not trigger the deprecation

fabpot added a commit that referenced this pull request May 24, 2017
This PR was merged into the 3.2 branch.

Discussion
----------

[DI] Check for privates before shared services

| Q             | A
| ------------- | ---
| Branch?       | 3.2
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #22801 (comment), #22801 (comment)
| License       | MIT
| Doc PR        | symfony/symfony-docs#... <!--highly recommended for new features-->

cc @stof

Commits
-------

4f683a9 [DI] Check for privates before shared services
symfony-splitter pushed a commit to symfony/web-profiler-bundle that referenced this pull request May 24, 2017
This PR was merged into the 3.2 branch.

Discussion
----------

[DI] Check for privates before shared services

| Q             | A
| ------------- | ---
| Branch?       | 3.2
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | symfony/symfony#22801 (comment), symfony/symfony#22801 (comment)
| License       | MIT
| Doc PR        | symfony/symfony-docs#... <!--highly recommended for new features-->

cc @stof

Commits
-------

4f683a9a5b [DI] Check for privates before shared services
@nicolas-grekas
Copy link
Member

rebase needed

@@ -299,7 +294,7 @@ public function initialized($id)
}

if (isset($this->privates[$id])) {
@trigger_error(sprintf('Checking for the initialization of the "%s" private service is deprecated since Symfony 3.4 and won\'t be supported anymore in Symfony 4.0.', $id), E_USER_DEPRECATED);
return false;
Copy link
Contributor Author
@ro0NL ro0NL Jul 12, 2017

Choose a reason for hiding this comment

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

@nicolas-grekas made a mistake here... alias ID resolution happens first. We dont do that in has etc.

Although i think we actually should do that =/ (could be a new feature and/or patch 3.3/4; wdyt?)

edit: see #23492

@nicolas-grekas
Copy link
Member

ping @ro0NL do you need help for this one? would be great to finish it before working on your other ones :)

@ro0NL
Copy link
Contributor Author
ro0NL commented Jul 17, 2017

@nicolas-grekas rebased. To me it's ready.. :)

@@ -225,8 +220,26 @@ public function has($id)
*/
public function get($id, $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE)
{
$serviceNotFound = function ($id) use ($invalidBehavior) {
Copy link
Member

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 correct. Perf wise, this will create a closure for each "get". But get is a perf critical piece, so that it should do as little as possible on each code path.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Would static $serviceNotFound = function ($id, $invalidBehavior) {} be better? Otherwise extract levenshtein into getAlternativeServiceIds() and inline from there?

Copy link
Member

Choose a reason for hiding this comment

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

I think there is no need for any levenstein reco for private services. There is no typo there.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

of course :) updated.

67E6

@ro0NL
Copy link
Contributor Author
ro0NL commented Jul 17, 2017

Perhaps something to start thinking about; are we allowed to break alias chains?

@nicolas-grekas
Copy link
Member

ie? isn't that something already handled by some compiler pass (resolving aliases?)

@ro0NL
Copy link
Contributor Author
ro0NL commented Jul 17, 2017

Hm, if you have public_service > some_alias > private_service, i believe doing $container->set('some_alias', $newService) at any point after compilation, happily unsets the alias and sets a new service in between.

Not really played with it yet, just looking at the code path :)

@nicolas-grekas
Copy link
Member

What I said: this is already resolved by a compiler pass so it cannot happen in practice.

@fabpot
Copy link
Member
fabpot commented Jul 17, 2017

Thank you @ro0NL.

@fabpot fabpot merged commit 9f96952 into symfony:master Jul 17, 2017
fabpot added a commit that referenced this pull request Jul 17, 2017
…rvices (ro0NL)

This PR was merged into the 4.0-dev branch.

Discussion
----------

[DI] Removed deprecated setting private/pre-defined services

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | yes
| 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-->

See #21533, #19708 and #19146

@nicolas-grekas privates should be excluded from `getServiceIds` right? i also wondered.. did we forget to deprecate checking privates with `initialized()`?

Commits
-------

9f96952 [DI] Removed deprecated setting private/pre-defined services
@ro0NL ro0NL deleted the di/privates-4.0 branch July 17, 2017 12:02
@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.

6 participants
0