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

Civi\Core\Container - Fix warning about Symfony 3=>4 and boot services #15704

Merged
merged 1 commit into from
Nov 2, 2019

Conversation

totten
Copy link
Member

@totten totten commented Nov 2, 2019

Overview

"Boot services" are initialized during bootstrap (before the container starts) -- and then passed into the container via $container->set().

Symfony 3.4 changes the default handling of set() - it now emits warnings unless the services were previously flagged as public.

https://symfony.com/blog/new-in-symfony-3-4-services-are-private-by-default

Before

[bknix-min:~/bknix/build/d8re] drush php
Psy Shell v0.9.9 (PHP 7.0.32 — cli) by Justin Hileman
>>> \Drupal::service('civicrm')->initialize();
PHP Deprecated:  The "runtime" service is private, replacing it is deprecated since Symfony 3.2 and will fail in 4.0. in /Users/totten/bknix/build/d8re/vendor/symfony/dependency-injection/Container.php on line 190
PHP Deprecated:  The "paths" service is private, replacing it is deprecated since Symfony 3.2 and will fail in 4.0. in /Users/totten/bknix/build/d8re/vendor/symfony/dependency-injection/Container.php on line 190
PHP Deprecated:  The "userSystem" service is private, replacing it is deprecated since Symfony 3.2 and will fail in 4.0. in /Users/totten/bknix/build/d8re/vendor/symfony/dependency-injection/Container.php on line 190
PHP Deprecated:  The "userPermissionClass" service is private, replacing it is deprecated since Symfony 3.2 and will fail in 4.0. in /Users/totten/bknix/build/d8re/vendor/symfony/dependency-injection/Container.php on line 190
PHP Deprecated:  The "cache.settings" service is private, replacing it is deprecated since Symfony 3.2 and will fail in 4.0. in /Users/totten/bknix/build/d8re/vendor/symfony/dependency-injection/Container.php on line 190
PHP Deprecated:  The "settings_manager" service is private, replacing it is deprecated since Symfony 3.2 and will fail in 4.0. in /Users/totten/bknix/build/d8re/vendor/symfony/dependency-injection/Container.php on line 190
PHP Deprecated:  The "lockManager" service is private, replacing it is deprecated since Symfony 3.2 and will fail in 4.0. in /Users/totten/bknix/build/d8re/vendor/symfony/dependency-injection/Container.php on line 190

After

The warnings don't appear.

Comments

The Definition class includes two methods, setPublic() and setPrivate(), which appear to do the same thing (but as opposites). setPublic() exists in Symfony 2.8+, but setPrivate() was added in Symfony 3.x, so we use setPublic() for broader compatibility.

Boot services are initialized before the container starts -- and then passed in via `$container->set()`.

Symfony 3.4 changes the default handling of `set()` - it now emits warnings
unless the services were previously flagged as public.

https://symfony.com/blog/new-in-symfony-3-4-services-are-private-by-default

Before
------

```
[bknix-min:~/bknix/build/d8re] drush php
Psy Shell v0.9.9 (PHP 7.0.32 — cli) by Justin Hileman
>>> \Drupal::service('civicrm')->initialize();
PHP Deprecated:  The "runtime" service is private, replacing it is deprecated since Symfony 3.2 and will fail in 4.0. in /Users/totten/bknix/build/d8re/vendor/symfony/dependency-injection/Container.php on line 190
PHP Deprecated:  The "paths" service is private, replacing it is deprecated since Symfony 3.2 and will fail in 4.0. in /Users/totten/bknix/build/d8re/vendor/symfony/dependency-injection/Container.php on line 190
PHP Deprecated:  The "userSystem" service is private, replacing it is deprecated since Symfony 3.2 and will fail in 4.0. in /Users/totten/bknix/build/d8re/vendor/symfony/dependency-injection/Container.php on line 190
PHP Deprecated:  The "userPermissionClass" service is private, replacing it is deprecated since Symfony 3.2 and will fail in 4.0. in /Users/totten/bknix/build/d8re/vendor/symfony/dependency-injection/Container.php on line 190
PHP Deprecated:  The "cache.settings" service is private, replacing it is deprecated since Symfony 3.2 and will fail in 4.0. in /Users/totten/bknix/build/d8re/vendor/symfony/dependency-injection/Container.php on line 190
PHP Deprecated:  The "settings_manager" service is private, replacing it is deprecated since Symfony 3.2 and will fail in 4.0. in /Users/totten/bknix/build/d8re/vendor/symfony/dependency-injection/Container.php on line 190
PHP Deprecated:  The "lockManager" service is private, replacing it is deprecated since Symfony 3.2 and will fail in 4.0. in /Users/totten/bknix/build/d8re/vendor/symfony/dependency-injection/Container.php on line 190
```

After
-----

The warnings don't appear.

Comments
--------

The `Definition` class includes two methods, `setPublic()` and
`setPrivate()`, which appear to do the same thing (but as opposites).
`setPublic()` exists Symfony 2.8+, but `setPrivate()` was added in Symfony
3.x, so we use `setPublic()` for broader compatibility.
@civibot
Copy link

civibot bot commented Nov 2, 2019

(Standard links)

@civibot civibot bot added the master label Nov 2, 2019
@eileenmcnaughton eileenmcnaughton merged commit a247fb2 into civicrm:master Nov 2, 2019
@totten totten deleted the master-container-warn branch November 2, 2019 22:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants