Skip to content

Commit

Permalink
Deprecates ClassCache-cache warmer.
Browse files Browse the repository at this point in the history
  • Loading branch information
Denis Brumann committed Dec 11, 2016
1 parent 51bc35c commit 660d79a
Show file tree
Hide file tree
Showing 17 changed files with 202 additions and 115 deletions.
Expand Up @@ -16,7 +16,7 @@
/**
* @author Bernhard Schussek <bschussek@gmail.com>
*
* @deprecated Deprecated since version 3.2, to be removed in 4.0.
* @deprecated since version 3.2, to be removed in 4.0.
*/
interface TwigRendererEngineInterface extends FormRendererEngineInterface
{
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bridge/Twig/Form/TwigRendererInterface.php
Expand Up @@ -16,7 +16,7 @@
/**
* @author Bernhard Schussek <bschussek@gmail.com>
*
* @deprecated Deprecated since version 3.2, to be removed in 4.0.
* @deprecated since version 3.2, to be removed in 4.0.
*/
interface TwigRendererInterface extends FormRendererInterface
{
Expand Down
Expand Up @@ -11,13 +11,19 @@

namespace Symfony\Bundle\FrameworkBundle\CacheWarmer;

if (PHP_VERSION_ID >= 70000) {
@trigger_error('The '.__NAMESPACE__.'\ClassCacheCacheWarmer class is deprecated since version 3.3 and will be removed in 4.0.', E_USER_DEPRECATED);
}

use Symfony\Component\ClassLoader\ClassCollectionLoader;
use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface;

/**
* Generates the Class Cache (classes.php) file.
*
* @author Tugdual Saunier <tucksaun@gmail.com>
*
* @deprecated since version 3.3, to be removed in 4.0.
*/
class ClassCacheCacheWarmer implements CacheWarmerInterface
{
Expand Down
Expand Up @@ -71,6 +71,14 @@ public function load(array $configs, ContainerBuilder $container)

$loader->load('web.xml');
$loader->load('services.xml');

if (PHP_VERSION_ID < 70000) {
$definition = $container->getDefinition('kernel.class_cache.cache_warmer');
$definition->addTag('kernel.cache_warmer');
// Ignore deprecation for PHP versions below 7.0
$definition->setDeprecated(false);
}

$loader->load('fragment_renderer.xml');

// Property access is used by both the Form and the Validator component
Expand Down Expand Up @@ -194,47 +202,49 @@ public function load(array $configs, ContainerBuilder $container)
'Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller',
));

$this->addClassesToCompile(array(
'Symfony\\Component\\Config\\ConfigCache',
'Symfony\\Component\\Config\\FileLocator',

'Symfony\\Component\\Debug\\ErrorHandler',

'Symfony\\Component\\DependencyInjection\\ContainerAwareInterface',
'Symfony\\Component\\DependencyInjection\\Container',

'Symfony\\Component\\EventDispatcher\\Event',
'Symfony\\Component\\EventDispatcher\\ContainerAwareEventDispatcher',

'Symfony\\Component\\HttpFoundation\\Response',
'Symfony\\Component\\HttpFoundation\\ResponseHeaderBag',

'Symfony\\Component\\HttpKernel\\EventListener\\ResponseListener',
'Symfony\\Component\\HttpKernel\\EventListener\\RouterListener',
'Symfony\\Component\\HttpKernel\\Bundle\\Bundle',
'Symfony\\Component\\HttpKernel\\Controller\\ControllerResolver',
'Symfony\\Component\\HttpKernel\\Controller\\ArgumentResolver',
'Symfony\\Component\\HttpKernel\\ControllerMetadata\\ArgumentMetadata',
'Symfony\\Component\\HttpKernel\\ControllerMetadata\\ArgumentMetadataFactory',
'Symfony\\Component\\HttpKernel\\Event\\KernelEvent',
'Symfony\\Component\\HttpKernel\\Event\\FilterControllerEvent',
'Symfony\\Component\\HttpKernel\\Event\\FilterResponseEvent',
'Symfony\\Component\\HttpKernel\\Event\\GetResponseEvent',
'Symfony\\Component\\HttpKernel\\Event\\GetResponseForControllerResultEvent',
'Symfony\\Component\\HttpKernel\\Event\\GetResponseForExceptionEvent',
'Symfony\\Component\\HttpKernel\\HttpKernel',
'Symfony\\Component\\HttpKernel\\KernelEvents',
'Symfony\\Component\\HttpKernel\\Config\\FileLocator',

'Symfony\\Bundle\\FrameworkBundle\\Controller\\ControllerNameParser',
'Symfony\\Bundle\\FrameworkBundle\\Controller\\ControllerResolver',

// Cannot be included because annotations will parse the big compiled class file
// 'Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller',

// cannot be included as commands are discovered based on the path to this class via Reflection
// 'Symfony\\Bundle\\FrameworkBundle\\FrameworkBundle',
));
if (PHP_VERSION_ID < 70000) {
$this->addClassesToCompile(array(
'Symfony\\Component\\Config\\ConfigCache',
'Symfony\\Component\\Config\\FileLocator',

'Symfony\\Component\\Debug\\ErrorHandler',

'Symfony\\Component\\DependencyInjection\\ContainerAwareInterface',
'Symfony\\Component\\DependencyInjection\\Container',

'Symfony\\Component\\EventDispatcher\\Event',
'Symfony\\Component\\EventDispatcher\\ContainerAwareEventDispatcher',

'Symfony\\Component\\HttpFoundation\\Response',
'Symfony\\Component\\HttpFoundation\\ResponseHeaderBag',

'Symfony\\Component\\HttpKernel\\EventListener\\ResponseListener',
'Symfony\\Component\\HttpKernel\\EventListener\\RouterListener',
'Symfony\\Component\\HttpKernel\\Bundle\\Bundle',
'Symfony\\Component\\HttpKernel\\Controller\\ControllerResolver',
'Symfony\\Component\\HttpKernel\\Controller\\ArgumentResolver',
'Symfony\\Component\\HttpKernel\\ControllerMetadata\\ArgumentMetadata',
'Symfony\\Component\\HttpKernel\\ControllerMetadata\\ArgumentMetadataFactory',
'Symfony\\Component\\HttpKernel\\Event\\KernelEvent',
'Symfony\\Component\\HttpKernel\\Event\\FilterControllerEvent',
'Symfony\\Component\\HttpKernel\\Event\\FilterResponseEvent',
'Symfony\\Component\\HttpKernel\\Event\\GetResponseEvent',
'Symfony\\Component\\HttpKernel\\Event\\GetResponseForControllerResultEvent',
'Symfony\\Component\\HttpKernel\\Event\\GetResponseForExceptionEvent',
'Symfony\\Component\\HttpKernel\\HttpKernel',
'Symfony\\Component\\HttpKernel\\KernelEvents',
'Symfony\\Component\\HttpKernel\\Config\\FileLocator',

'Symfony\\Bundle\\FrameworkBundle\\Controller\\ControllerNameParser',
'Symfony\\Bundle\\FrameworkBundle\\Controller\\ControllerResolver',

// Cannot be included because annotations will parse the big compiled class file
// 'Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller',

// cannot be included as commands are discovered based on the path to this class via Reflection
// 'Symfony\\Bundle\\FrameworkBundle\\FrameworkBundle',
));
}
}

/**
Expand Down Expand Up @@ -525,13 +535,15 @@ 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']);

$this->addClassesToCompile(array(
'Symfony\\Component\\Routing\\Generator\\UrlGenerator',
'Symfony\\Component\\Routing\\RequestContext',
'Symfony\\Component\\Routing\\Router',
'Symfony\\Bundle\\FrameworkBundle\\Routing\\RedirectableUrlMatcher',
$container->findDefinition('router.default')->getClass(),
));
if (PHP_VERSION_ID < 70000) {
$this->addClassesToCompile(array(
'Symfony\\Component\\Routing\\Generator\\UrlGenerator',
'Symfony\\Component\\Routing\\RequestContext',
'Symfony\\Component\\Routing\\Router',
'Symfony\\Bundle\\FrameworkBundle\\Routing\\RedirectableUrlMatcher',
$container->findDefinition('router.default')->getClass(),
));
}
}

/**
Expand Down Expand Up @@ -574,20 +586,22 @@ private function registerSessionConfiguration(array $config, ContainerBuilder $c

$container->setParameter('session.save_path', $config['save_path']);

$this->addClassesToCompile(array(
'Symfony\\Bundle\\FrameworkBundle\\EventListener\\SessionListener',
'Symfony\\Component\\HttpFoundation\\Session\\Storage\\NativeSessionStorage',
'Symfony\\Component\\HttpFoundation\\Session\\Storage\\PhpBridgeSessionStorage',
'Symfony\\Component\\HttpFoundation\\Session\\Storage\\Handler\\NativeFileSessionHandler',
'Symfony\\Component\\HttpFoundation\\Session\\Storage\\Proxy\\AbstractProxy',
'Symfony\\Component\\HttpFoundation\\Session\\Storage\\Proxy\\SessionHandlerProxy',
$container->getDefinition('session')->getClass(),
));

if ($container->hasDefinition($config['storage_id'])) {
if (PHP_VERSION_ID < 70000) {
$this->addClassesToCompile(array(
$container->findDefinition('session.storage')->getClass(),
'Symfony\\Bundle\\FrameworkBundle\\EventListener\\SessionListener',
'Symfony\\Component\\HttpFoundation\\Session\\Storage\\NativeSessionStorage',
'Symfony\\Component\\HttpFoundation\\Session\\Storage\\PhpBridgeSessionStorage',
'Symfony\\Component\\HttpFoundation\\Session\\Storage\\Handler\\NativeFileSessionHandler',
'Symfony\\Component\\HttpFoundation\\Session\\Storage\\Proxy\\AbstractProxy',
'Symfony\\Component\\HttpFoundation\\Session\\Storage\\Proxy\\SessionHandlerProxy',
$container->getDefinition('session')->getClass(),
));

if ($container->hasDefinition($config['storage_id'])) {
$this->addClassesToCompile(array(
$container->findDefinition('session.storage')->getClass(),
));
}
}

$container->setParameter('session.metadata.update_threshold', $config['metadata_update_threshold']);
Expand Down Expand Up @@ -657,12 +671,14 @@ private function registerTemplatingConfiguration(array $config, ContainerBuilder
$container->setDefinition('templating.loader', $loaderCache);
}

$this->addClassesToCompile(array(
'Symfony\\Bundle\\FrameworkBundle\\Templating\\GlobalVariables',
'Symfony\\Bundle\\FrameworkBundle\\Templating\\TemplateReference',
'Symfony\\Bundle\\FrameworkBundle\\Templating\\TemplateNameParser',
$container->findDefinition('templating.locator')->getClass(),
));
if (PHP_VERSION_ID < 70000) {
$this->addClassesToCompile(array(
'Symfony\\Bundle\\FrameworkBundle\\Templating\\GlobalVariables',
'Symfony\\Bundle\\FrameworkBundle\\Templating\\TemplateReference',
'Symfony\\Bundle\\FrameworkBundle\\Templating\\TemplateNameParser',
$container->findDefinition('templating.locator')->getClass(),
));
}

$container->setParameter('templating.engines', $config['engines']);
$engines = array_map(function ($engine) { return new Reference('templating.engine.'.$engine); }, $config['engines']);
Expand Down Expand Up @@ -695,11 +711,13 @@ private function registerTemplatingConfiguration(array $config, ContainerBuilder
$container->setAlias('debug.templating.engine.php', 'templating.engine.php');
}

$this->addClassesToCompile(array(
'Symfony\\Component\\Templating\\Storage\\FileStorage',
'Symfony\\Bundle\\FrameworkBundle\\Templating\\PhpEngine',
'Symfony\\Bundle\\FrameworkBundle\\Templating\\Loader\\FilesystemLoader',
));
if (PHP_VERSION_ID < 70000) {
$this->addClassesToCompile(array(
'Symfony\\Component\\Templating\\Storage\\FileStorage',
'Symfony\\Bundle\\FrameworkBundle\\Templating\\PhpEngine',
'Symfony\\Bundle\\FrameworkBundle\\Templating\\Loader\\FilesystemLoader',
));
}

if ($container->has('assets.packages')) {
$container->getDefinition('templating.helper.assets')->replaceArgument(0, new Reference('assets.packages'));
Expand Down Expand Up @@ -1015,10 +1033,12 @@ private function registerAnnotationsConfiguration(array $config, ContainerBuilde
$definition = $container->findDefinition('annotations.cache_warmer');
$definition->addTag('kernel.cache_warmer');

$this->addClassesToCompile(array(
'Symfony\Component\Cache\Adapter\PhpArrayAdapter',
'Symfony\Component\Cache\DoctrineProvider',
));
if (PHP_VERSION_ID < 70000) {
$this->addClassesToCompile(array(
'Symfony\Component\Cache\Adapter\PhpArrayAdapter',
'Symfony\Component\Cache\DoctrineProvider',
));
}
} elseif ('file' === $config['cache']) {
$cacheDir = $container->getParameterBag()->resolveValue($config['file_cache_dir']);

Expand Down Expand Up @@ -1270,11 +1290,13 @@ private function registerCacheConfiguration(array $config, ContainerBuilder $con
$propertyAccessDefinition->addTag('monolog.logger', array('channel' => 'cache'));
}

$this->addClassesToCompile(array(
'Symfony\Component\Cache\Adapter\ApcuAdapter',
'Symfony\Component\Cache\Adapter\FilesystemAdapter',
'Symfony\Component\Cache\CacheItem',
));
if (PHP_VERSION_ID < 70000) {
$this->addClassesToCompile(array(
'Symfony\Component\Cache\Adapter\ApcuAdapter',
'Symfony\Component\Cache\Adapter\FilesystemAdapter',
'Symfony\Component\Cache\CacheItem',
));
}
}

/**
Expand Down
Expand Up @@ -25,16 +25,15 @@
</service>

<service id="kernel.class_cache.cache_warmer" class="Symfony\Bundle\FrameworkBundle\CacheWarmer\ClassCacheCacheWarmer">
<tag name="kernel.cache_warmer" />
<argument type="collection">
<argument>Symfony\Component\HttpFoundation\ParameterBag</argument>
<argument>Symfony\Component\HttpFoundation\HeaderBag</argument>
<argument>Symfony\Component\HttpFoundation\FileBag</argument>
<argument>Symfony\Component\HttpFoundation\ServerBag</argument>
<argument>Symfony\Component\HttpFoundation\Request</argument>
<argument>Symfony\Component\HttpKernel\Kernel</argument>
<argument>Symfony\Component\ClassLoader\ClassCollectionLoader</argument>
</argument>
<deprecated>The "%service_id%" option is deprecated since version 3.3, to be removed in 4.0.</deprecated>
</service>

<service id="cache_clearer" class="Symfony\Component\HttpKernel\CacheClearer\ChainCacheClearer">
Expand Down
Expand Up @@ -16,6 +16,9 @@
use Symfony\Bundle\FrameworkBundle\Tests\Fixtures\WarmedClass;
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;

/**
* @group legacy
*/
class ClassCacheCacheWarmerTest extends TestCase
{
public function testWithDeclaredClasses()
Expand Down
Expand Up @@ -101,20 +101,22 @@ public function load(array $configs, ContainerBuilder $container)
$this->aclLoad($config['acl'], $container);
}

// add some required classes for compilation
$this->addClassesToCompile(array(
'Symfony\Component\Security\Http\Firewall',
'Symfony\Component\Security\Core\User\UserProviderInterface',
'Symfony\Component\Security\Core\Authentication\AuthenticationProviderManager',
'Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage',
'Symfony\Component\Security\Core\Authorization\AccessDecisionManager',
'Symfony\Component\Security\Core\Authorization\AuthorizationChecker',
'Symfony\Component\Security\Core\Authorization\Voter\VoterInterface',
'Symfony\Bundle\SecurityBundle\Security\FirewallConfig',
'Symfony\Bundle\SecurityBundle\Security\FirewallMap',
'Symfony\Bundle\SecurityBundle\Security\FirewallContext',
'Symfony\Component\HttpFoundation\RequestMatcher',
));
if (PHP_VERSION_ID < 70000) {
// add some required classes for compilation
$this->addClassesToCompile(array(
'Symfony\Component\Security\Http\Firewall',
'Symfony\Component\Security\Core\User\UserProviderInterface',
'Symfony\Component\Security\Core\Authentication\AuthenticationProviderManager',
'Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage',
'Symfony\Component\Security\Core\Authorization\AccessDecisionManager',
'Symfony\Component\Security\Core\Authorization\AuthorizationChecker',
'Symfony\Component\Security\Core\Authorization\Voter\VoterInterface',
'Symfony\Bundle\SecurityBundle\Security\FirewallConfig',
'Symfony\Bundle\SecurityBundle\Security\FirewallMap',
'Symfony\Bundle\SecurityBundle\Security\FirewallContext',
'Symfony\Component\HttpFoundation\RequestMatcher',
));
}
}

private function aclLoad($config, ContainerBuilder $container)
Expand Down Expand Up @@ -191,9 +193,11 @@ private function createAuthorization($config, ContainerBuilder $container)
return;
}

$this->addClassesToCompile(array(
'Symfony\\Component\\Security\\Http\\AccessMap',
));
if (PHP_VERSION_ID < 70000) {
$this->addClassesToCompile(array(
'Symfony\\Component\\Security\\Http\\AccessMap',
));
}

foreach ($config['access_control'] as $access) {
$matcher = $this->createRequestMatcher(
Expand Down
22 changes: 12 additions & 10 deletions src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php
Expand Up @@ -126,16 +126,18 @@ public function load(array $configs, ContainerBuilder $container)

$container->getDefinition('twig')->replaceArgument(1, $config);

$this->addClassesToCompile(array(
'Twig_Environment',
'Twig_Extension',
'Twig_Extension_Core',
'Twig_Extension_Escaper',
'Twig_Extension_Optimizer',
'Twig_LoaderInterface',
'Twig_Markup',
'Twig_Template',
));
if (PHP_VERSION_ID < 70000) {
$this->addClassesToCompile(array(
'Twig_Environment',
'Twig_Extension',
'Twig_Extension_Core',
'Twig_Extension_Escaper',
'Twig_Extension_Optimizer',
'Twig_LoaderInterface',
'Twig_Markup',
'Twig_Template',
));
}
}

private function addTwigPath($twigFilesystemLoaderDefinition, $dir, $bundle)
Expand Down

0 comments on commit 660d79a

Please sign in to comment.