Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 18edda3

Browse filesBrowse files
committed
bug #26193 Fix false-positive deprecation notices for TranslationLoader and WriteCheckSessionHandler (iquito)
This PR was squashed before being merged into the 3.4 branch (closes #26193). Discussion ---------- Fix false-positive deprecation notices for TranslationLoader and WriteCheckSessionHandler | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #25518 | License | MIT Symfony 3.4 emits deprecation warnings for `TranslationLoader` and `WriteCheckSessionHandler` as soon as these classes are loaded, yet at the same time these classes are part of the default services defined in Symfony 3.4, so if these classes are loaded during container compilation a deprecation warning is emitted, even if these classes are never actually used. An example would be the following within a compiler pass: foreach ($containerBuilder->getDefinitions() as $definition) { if (is_subclass_of($definition->getClass(), SomeClass::class)) { $definition->addMethodCall('setSomething', [new Reference('someservice')]); } } This will load both `TranslationLoader` and `WriteCheckSessionHandler` in order to check their definition. No instance of the classes are ever used and the classes are not loaded after compilation ever, yet the deprecation notices are shown on every single page. More details are provided in issue #25518 . By moving the deprecation notices to the class constructors false-positives are avoided while actual usage of the classes should still generate the deprecation warnings. Commits ------- 1a427b1 Fix false-positive deprecation notices for TranslationLoader and WriteCheckSessionHandler
2 parents e183c58 + 1a427b1 commit 18edda3
Copy full SHA for 18edda3

File tree

2 files changed

+7
-4
lines changed
Filter options

2 files changed

+7
-4
lines changed

‎src/Symfony/Bundle/FrameworkBundle/Translation/TranslationLoader.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Translation/TranslationLoader.php
+5-2Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,16 @@
1414
use Symfony\Component\Translation\Reader\TranslationReader;
1515
use Symfony\Component\Translation\MessageCatalogue;
1616

17-
@trigger_error(sprintf('The class "%s" is deprecated since Symfony 3.4 and will be removed in 4.0. Use "%s" instead. ', TranslationLoader::class, TranslationReader::class), E_USER_DEPRECATED);
18-
1917
/**
2018
* @deprecated since version 3.4 and will be removed in 4.0. Use Symfony\Component\Translation\Reader\TranslationReader instead
2119
*/
2220
class TranslationLoader extends TranslationReader
2321
{
22+
public function __construct()
23+
{
24+
@trigger_error(sprintf('The class "%s" is deprecated since Symfony 3.4 and will be removed in 4.0. Use "%s" instead. ', self::class, TranslationReader::class), E_USER_DEPRECATED);
25+
}
26+
2427
/**
2528
* Loads translation messages from a directory to the catalogue.
2629
*

‎src/Symfony/Component/HttpFoundation/Session/Storage/Handler/WriteCheckSessionHandler.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/Session/Storage/Handler/WriteCheckSessionHandler.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
namespace Symfony\Component\HttpFoundation\Session\Storage\Handler;
1313

14-
@trigger_error(sprintf('The %s class is deprecated since Symfony 3.4 and will be removed in 4.0. Implement `SessionUpdateTimestampHandlerInterface` or extend `AbstractSessionHandler` instead.', WriteCheckSessionHandler::class), E_USER_DEPRECATED);
15-
1614
/**
1715
* Wraps another SessionHandlerInterface to only write the session when it has been modified.
1816
*
@@ -31,6 +29,8 @@ class WriteCheckSessionHandler implements \SessionHandlerInterface
3129

3230
public function __construct(\SessionHandlerInterface $wrappedSessionHandler)
3331
{
32+
@trigger_error(sprintf('The %s class is deprecated since Symfony 3.4 and will be removed in 4.0. Implement `SessionUpdateTimestampHandlerInterface` or extend `AbstractSessionHandler` instead.', self::class), E_USER_DEPRECATED);
33+
3434
$this->wrappedSessionHandler = $wrappedSessionHandler;
3535
}
3636

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.