-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Deprecate ClassCollectionLoader and Kernel::loadClassCache #20735
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
Conversation
*/ | ||
public function loadClassCache($name = 'classes', $extension = '.php') | ||
{ | ||
@trigger_error('loadClassCache() is deprecated since 3.3, to be removed in 4.0.', E_USER_DEPRECATED); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extra space before since
That's a good first step, but there are other parts of the code to change, like any usages of |
The The |
I still have some issues in functional tests probably related to deprecating ClassCacheWarmer (see AppVeyor results). For instance I assume that I have to adjust FrameworkBundle's AddCacheWarmerPass to exclude Another question that remains for me is how we will address deprecation warnings in tests for php versions lower than PHP 7 as these should still use the depreacted class cache. I don't think it's practical to annotate these tests with |
@@ -531,6 +542,10 @@ private function registerRouterConfiguration(array $config, ContainerBuilder $co | |||
$container->setParameter('request_listener.http_port', $config['http_port']); | |||
$container->setParameter('request_listener.https_port', $config['https_port']); | |||
|
|||
if (PHP_VERSION_ID >= 7000 || !method_exists($this, 'addClassesToCompile')) { | |||
return; | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would wrap the next call instead of returning early here to make the intent clear.
use Symfony\Component\ClassLoader\ClassCollectionLoader; | ||
use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface; | ||
|
||
/** | ||
* Generates the Class Cache (classes.php) file. | ||
* | ||
* @author Tugdual Saunier <[email protected]> | ||
* | ||
* @deprecated Deprecated since version 3.3, to be removed in 4.0. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deprecated
@@ -71,6 +72,12 @@ public function load(array $configs, ContainerBuilder $container) | |||
|
|||
$loader->load('web.xml'); | |||
$loader->load('services.xml'); | |||
|
|||
if (PHP_VERSION_ID < 70000) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will still trigger a deprecation warning for PHP 5.6 users. Do we want it ?
// 'Symfony\\Bundle\\FrameworkBundle\\FrameworkBundle', | ||
)); | ||
if (PHP_VERSION_ID < 70000) { | ||
$this->addClassesToCompile(array( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here about deprecation warnings
|
@@ -34,6 +33,7 @@ | |||
<argument>Symfony\Component\ClassLoader\ClassCollectionLoader</argument> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should remove this line
/** | ||
* ClassCollectionLoader. | ||
* | ||
* @author Fabien Potencier <[email protected]> | ||
* | ||
* @deprecated Deprecated since version 3.3, to be removed in 4.0. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@deprecated since version 3.3, to be removed in 4.0.
(same below: no need to duplicate the "deprecated" word)
@nicolas-grekas can you reproduce your benchmark on PHP 5.6 as well ? I would really prefer to stop using it for all PHP versions rather than keeping usage of deprecated APIs in the core on PHP 5.6 (which would mean that users cannot get rid of deprecation warnings) |
*/ | ||
public function loadClassCache($name = 'classes', $extension = '.php') | ||
{ | ||
@trigger_error('loadClassCache() is deprecated since version 3.3, to be removed in 4.0.', E_USER_DEPRECATED); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Kernel::loadClassCache() method ... (same below and above)
We could think about triggering the deprecations on PHP < 7.0 (or maybe < 5.6) only. Besides that we have to realise that Symfony 4.0 will have to drop support for PHP versions < 7.0 (or < 5.6 if the benchmark turns out to be promising for it too). Otherwise the deprecations wouldn't make much sense. |
I don't think so. Why? |
@nicolas-grekas isn't it part of the same feature set ? |
@nicolas-grekas have you tried the same benchmark on PHP 5.6 to see whether we could deprecate the feature for all PHP versions instead, which would be much simpler ? Regarding addAnnotatedClassesToCompile, I was confused about what it does due to its naming: it does not compile the classes at all. These classes are just classes for which the annotation cache is warmed up. |
@stof you mean PHP 5.5 (our lowest supported version?) I didn't check but the optims that allow PHP7 to be faster do not exists on 5.5 so I'm pretty sure inlining still wins on 5.5. About addAnnotatedClassesToCompile, you're right. |
hmm yeah, I forgot the lowest bound in 5.5.9, not 5.6. |
@stof I would not want to give php 5.5 users a sudden performance penalty just because we don't like that feature anymore. People who are pinned to php 5.5 (for whatever reason) are thankful for optimizations like this one. |
@xabbuh and @nicolas-grekas is there already a way to trigger deprecation warnings conditionally? If not, what would be the best way to go about it? @stof we had the discussion about performance penalty on older php versions during the SymfonyCon hackday and consensus seemed to be that we should avoid it. |
This would be the first time, but it should be just a matter of wrapping the deprecation in a check against |
I don't have 5.6 anymore so if someone could give it a try, please do. |
*/ | ||
public function addClassesToCompile(array $classes) | ||
{ | ||
@trigger_error('Extension::loadClassCache() is deprecated since version 3.3, to be removed in 4.0.', E_USER_DEPRECATED); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fqcn, + wrong method name, isn't it?
use Symfony\Component\HttpKernel\DependencyInjection\AddClassesToCachePass; | ||
use Symfony\Component\HttpKernel\DependencyInjection\MergeExtensionConfigurationPass; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No reorder, to save us some merge conflicts
*/ | ||
public function loadClassCache($name = 'classes', $extension = '.php') | ||
{ | ||
@trigger_error('Kernel::loadClassCache() is deprecated since version 3.3, to be removed in 4.0.', E_USER_DEPRECATED); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fqcn
*/ | ||
public function setClassCache(array $classes) | ||
{ | ||
@trigger_error('Kernel::setClassCache() is deprecated since version 3.3, to be removed in 4.0.', E_USER_DEPRECATED); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fqcn
protected function doLoadClassCache($name, $extension) | ||
{ | ||
@trigger_error('Kernel::doLoadClassCache() is deprecated since version 3.3, to be removed in 4.0.', E_USER_DEPRECATED); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fqcn
…ann) This PR was submitted for the master branch but it was merged into the 2.7 branch instead (closes #7243). Discussion ---------- Removes duplicated Deprecated and adds an example. Removes the duplicate "Deprecated" after `@deprecated` annotation as was asked in my PR symfony/symfony#20735. Also adds a randomly selected example that shows how the abstract `XXX` should look like and an edge case of `trigger_error()` when deprecating a whole class. Commits ------- a2c04e7 Deletes duplicate "Deprecated" and adds a more explicit example.
👍 |
Thank you @dbrumann. |
…ache (dbrumann) This PR was merged into the 3.3-dev branch. Discussion ---------- Deprecate ClassCollectionLoader and Kernel::loadClassCache | Q | A | ------------- | --- | Branch? | "master" | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | yes | Tests pass? | yes | Fixed tickets | #20668 | License | MIT As suggested by @nicolas-grekas in #20668 I added deprecation notices to ClassCollectionLoader and Kernel::loadClassCache. Commits ------- 660d79a Deprecates ClassCache-cache warmer.
…oCompile() / AddClassesToCachePass (nicolas-grekas) This PR was merged into the 3.3-dev branch. Discussion ---------- [HttpKernel] Fix deprecation of Extension::addClassesToCompile() / AddClassesToCachePass | Q | A | ------------- | --- | Branch? | 3.3 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - As done in #20735 Commits ------- f4b5784 [HttpKernel] Fix deprecation of Extension::addClassesToCompile() / AddClassesToCachePass
…oCompile() / AddClassesToCachePass (nicolas-grekas) This PR was merged into the 3.3-dev branch. Discussion ---------- [HttpKernel] Fix deprecation of Extension::addClassesToCompile() / AddClassesToCachePass | Q | A | ------------- | --- | Branch? | 3.3 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - As done in symfony/symfony#20735 Commits ------- f4b5784 [HttpKernel] Fix deprecation of Extension::addClassesToCompile() / AddClassesToCachePass
… & Kernel::loadClassCache (ogizanagi, xabbuh) This PR was merged into the 4.0-dev branch. Discussion ---------- [ClassLoader][HttpKernel] Remove ClassLoader component & Kernel::loadClassCache | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? |no | BC breaks? | yes | Deprecations? | no | Tests pass? | yes | Fixed tickets | #20735 | License | MIT | Doc PR | N/A As deprecated in #20735 Commits ------- 551aaef [ClassLoader] remove the component 4f8916c [ClassLoader][HttpKernel] Remove ClassCollectionLoader & Kernel::loadClassCache BC layer
As suggested by @nicolas-grekas in #20668 I added deprecation notices to ClassCollectionLoader and Kernel::loadClassCache.