Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

Merged
merged 1 commit into from
Jan 6, 2017
Merged

Deprecate ClassCollectionLoader and Kernel::loadClassCache #20735

merged 1 commit into from
Jan 6, 2017

Conversation

dbrumann
Copy link
Contributor

@dbrumann dbrumann commented Dec 3, 2016

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.

@dbrumann dbrumann changed the title #20668 Deprecate ClassCollectionLoader and Kernel::loadC… Deprecate ClassCollectionLoader and Kernel::loadClassCache Dec 3, 2016
*/
public function loadClassCache($name = 'classes', $extension = '.php')
{
@trigger_error('loadClassCache() is deprecated since 3.3, to be removed in 4.0.', E_USER_DEPRECATED);
Copy link
Member

Choose a reason for hiding this comment

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

extra space before since

@fabpot
Copy link
Member

fabpot commented Dec 3, 2016

That's a good first step, but there are other parts of the code to change, like any usages of ClassCollectionLoader like in ClassCacheCacheWarmer.

@fabpot
Copy link
Member

fabpot commented Dec 3, 2016

The ClassCacheCacheWarmer should be deprecated as well, and the same goes for Kernel::setClassCache().

The Symfony\Component\HttpKernel\DependencyInjection\Extension::addClassesToCompile() method should also be deprecated.

@dbrumann
Copy link
Contributor Author

dbrumann commented Dec 3, 2016

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 kernel.class_cache.cache_warmer when PHP 7.x is being used?

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 @group legacy. @nicolas-grekas maybe you have an advice how to approach this?

@@ -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;
}
Copy link
Member

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.
Copy link
Member

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) {
Copy link
Member

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(
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 about deprecation warnings

@stof
Copy link
Member

stof commented Dec 6, 2016

Kernel::addAnnotatedClassesToCompile must also be deprecated

@@ -34,6 +33,7 @@
<argument>Symfony\Component\ClassLoader\ClassCollectionLoader</argument>
Copy link
Member

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.
Copy link
Member

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)

@stof
Copy link
Member

stof commented Dec 6, 2016

@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);
Copy link
Member

@nicolas-grekas nicolas-grekas Dec 6, 2016

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)

@xabbuh
Copy link
Member

xabbuh commented Dec 6, 2016

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.

@nicolas-grekas
Copy link
Member

Kernel::addAnnotatedClassesToCompile must also be deprecated

I don't think so. Why?

@stof
Copy link
Member

stof commented Dec 6, 2016

@nicolas-grekas isn't it part of the same feature set ?

@nicolas-grekas
Copy link
Member

@xabbuh do you mean triggering them on PHP >= 7.0? That's a good idea! Moving to 4.0 is going to require moving to PHP 7 before so it really makes sense. @dbrumann can you take care of that also please?

@stof Kernel::addAnnotatedClassesToCompile is especially usefull on PHP 7, so we should keep it.

@stof
Copy link
Member

stof commented Dec 6, 2016

@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.

@nicolas-grekas
Copy link
Member

@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.

@stof
Copy link
Member

stof commented Dec 6, 2016

hmm yeah, I forgot the lowest bound in 5.5.9, not 5.6.
Would still be good to know what happens on 5.6 (which has the composer classmap optimization).
If we only need it for PHP 5.5, we might stop using the deprecated feature for it IMO, as PHP 5.5 is already EOLed (and people really caring about such autoloading performance improvement should update to 5.6+ to have the composer optims)

@nicolas-grekas nicolas-grekas added this to the 3.x milestone Dec 6, 2016
@derrabus
Copy link
Member

derrabus commented Dec 6, 2016

@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.

@dbrumann
Copy link
Contributor Author

@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.

@nicolas-grekas
Copy link
Member

This would be the first time, but it should be just a matter of wrapping the deprecation in a check against PHP_VERSION_ID as you already did in other places.
For php 5.5, I don't have recent numbers, but I saw several benchs that demonstrated the benefit of inlining, so we should keep it I agree.

@nicolas-grekas
Copy link
Member

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);
Copy link
Member

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;
Copy link
Member

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);
Copy link
Member

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);
Copy link
Member

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);
Copy link
Member

Choose a reason for hiding this comment

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

Fqcn

xabbuh added a commit to symfony/symfony-docs that referenced this pull request Dec 13, 2016
…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.
@nicolas-grekas
Copy link
Member

👍

@nicolas-grekas nicolas-grekas modified the milestones: 3.3, 3.x Jan 6, 2017
@fabpot
Copy link
Member

fabpot commented Jan 6, 2017

Thank you @dbrumann.

@fabpot fabpot merged commit 660d79a into symfony:master Jan 6, 2017
fabpot added a commit that referenced this pull request Jan 6, 2017
…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.
fabpot added a commit that referenced this pull request Apr 19, 2017
…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
symfony-splitter pushed a commit to symfony/http-kernel that referenced this pull request Apr 19, 2017
…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
@fabpot fabpot mentioned this pull request May 1, 2017
nicolas-grekas added a commit that referenced this pull request May 21, 2017
… & 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
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.

7 participants