8000 [FrameworkBundle] Remove deprecated code · symfony/symfony@531156e · GitHub
[go: up one dir, main page]

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 531156e

Browse files
committed
[FrameworkBundle] Remove deprecated code
1 parent 4d9d8cb commit 531156e

File tree

14 files changed

+26
-443
lines changed

14 files changed

+26
-443
lines changed

src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ CHANGELOG
1111
`RoutingResolverPass`, `SerializerPass`, `ValidateWorkflowsPass`
1212
* made `Translator::__construct()` `$defaultLocale` argument required
1313
* removed `SessionListener`, `TestSessionListener`
14+
* Removed `cache:clear` warmup part along with the `--no-optional-warmers` option
15+
* Removed core form types services registration when unnecessary
16+
* Removed `framework.serializer.cache` option and `serializer.mapping.cache.apc`, `serializer.mapping.cache.doctrine.apc` services
17+
* Removed `ConstraintValidatorFactory::$validators` and `ConstraintValidatorFactory::$container` protected properties
18+
* Removed class parameters related to routing
19+
* Removed absolute template paths support in the template name parser
1420

1521
3.3.0
1622
-----

src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php

Lines changed: 6 additions & 191 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
use Symfony\Component\Console\Input\InputOption;
1616
use Symfony\Component\Console\Output\OutputInterface;
1717
use Symfony\Component\Console\Style\SymfonyStyle;
18-
use Symfony\Component\HttpKernel\KernelInterface;
19-
use Symfony\Component\Finder\Finder;
2018

2119
/**
2220
* Clear and Warmup the cache.
@@ -34,8 +32,7 @@ protected function configure()
3432
$this
3533
->setName('cache:clear')
3634
->setDefinition(array(
37-
new InputOption('no-warmup', '', InputOption::VALUE_NONE, 'Do not warm up the cache'),
38-
new InputOption('no-optional-warmers', '', InputOption::VALUE_NONE, 'Skip optional cache warmers (faster)'),
35+
new InputOption('no-warmup', '', InputOption::VALUE_NONE, 'Noop. Will be deprecated in 4.1 to be removed in 5.0.'),
3936
))
4037
->setDescription('Clears the cache')
4138
->setHelp(<<<'EOF'
@@ -56,209 +53,27 @@ protected function execute(InputInterface $input, OutputInterface $output)
5653
{
5754
$io = new SymfonyStyle($input, $output);
5855

59-
$realCacheDir = $this->getContainer()->getParameter('kernel.cache_dir');
60-
// the old cache dir name must not be longer than the real one to avoid exceeding
61-
// the maximum length of a directory or file path within it (esp. Windows MAX_PATH)
62-
$oldCacheDir = substr($realCacheDir, 0, -1).('~' === substr($realCacheDir, -1) ? '+' : '~');
56+
$cacheDir = $this->getContainer()->getParameter('kernel.cache_dir');
6357
$filesystem = $this->getContainer()->get('filesystem');
6458

65-
if (!is_writable($realCacheDir)) {
66-
throw new \RuntimeException(sprintf('Unable to write in the "%s" directory', $realCacheDir));
67-
}
68-
69-
if ($filesystem->exists($oldCacheDir)) {
70-
$filesystem->remove($oldCacheDir);
59+
if (!is_writable($cacheDir)) {
60+
throw new \RuntimeException(sprintf('Unable to write in the "%s" directory', $cacheDir));
7161
}
7262

7363
$kernel = $this->getContainer()->get('kernel');
7464
$io->comment(sprintf('Clearing the cache for the <info>%s</info> environment with debug <info>%s</info>', $kernel->getEnvironment(), var_export($kernel->isDebug(), true)));
75-
$this->getContainer()->get('cache_clearer')->clear($realCacheDir);
76-
77-
if ($input->getOption('no-warmup')) {
78-
$filesystem->rename($realCacheDir, $oldCacheDir);
79-
} else {
80-
@trigger_error('Calling cache:clear without the --no-warmup option is deprecated since version 3.3. Cache warmup should be done with the cache:warmup command instead.', E_USER_DEPRECATED);
81-
82-
$this->warmupCache($input, $output, $realCacheDir, $oldCacheDir);
83-
}
65+
$this->getContainer()->get('cache_clearer')->clear($cacheDir);
8466

8567
if ($output->isVerbose()) {
8668
$io->comment('Removing old cache directory...');
8769
}
8870

89-
$filesystem->remove($oldCacheDir);
71+
$filesystem->remove($cacheDir);
9072

9173
if ($output->isVerbose()) {
9274
$io->comment('Finished');
9375
}
9476

9577
$io->success(sprintf('Cache for the "%s" environment (debug=%s) was successfully cleared.', $kernel->getEnvironment(), var_export($kernel->isDebug(), true)));
9678
}
97-
98-
private function warmupCache(InputInterface $input, OutputInterface $output, $realCacheDir, $oldCacheDir)
99-
{
100-
$filesystem = $this->getContainer()->get('filesystem');
101-
$io = new SymfonyStyle($input, $output);
102-
103-
// the warmup cache dir name must have the same length than the real one
104-
// to avoid the many problems in serialized resources files
105-
$realCacheDir = realpath($realCacheDir);
106-
$warmupDir = substr($realCacheDir, 0, -1).('_' === substr($realCacheDir, -1) ? '-' : '_');
107-
108-
if ($filesystem->exists($warmupDir)) {
109-
if ($output->isVerbose()) {
110-
$io->comment('Clearing outdated warmup directory...');
111-
}
112-
$filesystem->remove($warmupDir);
113-
}
114-
115-
if ($output->isVerbose()) {
116-
$io->comment('Warming up cache...');
117-
}
118-
$this->warmup($warmupDir, $realCacheDir, !$input->getOption('no-optional-warmers'));
119-
120-
$filesystem->rename($realCacheDir, $oldCacheDir);
121-
if ('\\' === DIRECTORY_SEPARATOR) {
122-
sleep(1); // workaround for Windows PHP rename bug
123-
}
124-
$filesystem->rename($warmupDir, $realCacheDir);
125-
}
126-
127-
/**
128-
* @param string $warmupDir
129-
* @param string $realCacheDir
130-
* @param bool $enableOptionalWarmers
131-
*
132-
* @internal to be removed in 4.0
133-
*/
134-
protected function warmup($warmupDir, $realCacheDir, $enableOptionalWarmers = true)
135-
{
136-
// create a temporary kernel
137-
$realKernel = $this->getContainer()->get('kernel');
138-
$realKernelClass = get_class($realKernel);
139-
$namespace = '';
140-
if (false !== $pos = strrpos($realKernelClass, '\\')) {
141-
$namespace = substr($realKernelClass, 0, $pos);
142-
$realKernelClass = substr($realKernelClass, $pos + 1);
143-
}
144-
$tempKernel = $this->getTempKernel($realKernel, $namespace, $realKernelClass, $warmupDir);
145-
$tempKernel->boot();
146-
147-
$tempKernelReflection = new \ReflectionObject($tempKernel);
148-
$tempKernelFile = $tempKernelReflection->getFileName();
149-
150-
// warmup temporary dir
151-
$warmer = $tempKernel->getContainer()->get('cache_warmer');
152-
if ($enableOptionalWarmers) {
153-
$warmer->enableOptionalWarmers();
154-
}
155-
$warmer->warmUp($warmupDir);
156-
157-
// fix references to the Kernel in .meta files
158-
$safeTempKernel = str_replace('\\', '\\\\', get_class($tempKernel));
159-
$realKernelFQN = get_class($realKernel);
160-
161-
foreach (Finder::create()->files()->name('*.meta')->in($warmupDir) as $file) {
162-
file_put_contents($file, preg_replace(
163-
'/(C\:\d+\:)"'.$safeTempKernel.'"/',
164-
sprintf('$1"%s"', $realKernelFQN),
165-
file_get_contents($file)
166-
));
167-
}
168-
169-
// fix references to cached files with the real cache directory name
170-
$search = array($warmupDir, str_replace('\\', '\\\\', $warmupDir));
171-
$replace = str_replace('\\', '/', $realCacheDir);
172-
foreach (Finder::create()->files()->in($warmupDir) as $file) {
173-
$content = str_replace($search, $replace, file_get_contents($file));
174-
file_put_contents($file, $content);
175-
}
176-
177-
// fix references to container's class
178-
$tempContainerClass = get_class($tempKernel->getContainer());
179-
$realContainerClass = get_class($realKernel->getContainer());
180-
foreach (Finder::create()->files()->name($tempContainerClass.'*')->in($warmupDir) as $file) {
181-
$content = str_replace($tempContainerClass, $realContainerClass, file_get_contents($file));
182-
file_put_contents($file, $content);
183-
rename($file, str_replace(DIRECTORY_SEPARATOR.$tempContainerClass, DIRECTORY_SEPARATOR.$realContainerClass, $file));
184-
}
185-
186-
// remove temp kernel file after cache warmed up
187-
@unlink($tempKernelFile);
188-
}
189-
190-
/**
191-
* @param KernelInterface $parent
192-
* @param string $namespace
193-
* @param string $parentClass
194-
* @param string $warmupDir
195-
*
196-
* @return KernelInterface
197-
*
198-
* @internal to be removed in 4.0
199-
*/
200-
protected function getTempKernel(KernelInterface $parent, $namespace, $parentClass, $warmupDir)
201-
{
202-
$cacheDir = var_export($warmupDir, true);
203-
$rootDir = var_export(realpath($parent->getRootDir()), true);
204-
$logDir = var_export(realpath($parent->getLogDir()), true);
205-
// the temp kernel class name must have the same length than the real one
206-
// to avoid the many problems in serialized resources files
207-
$class = substr($parentClass, 0, -1).'_';
208-
// the temp container class must be changed too
209-
$containerClass = var_export(substr(get_class($parent->getContainer()), 0, -1).'_', true);
210-
$code = <<<EOF
211-
<?php
212-
213-
namespace $namespace
214-
{
215-
class $class extends $parentClass
216-
{
217-
public function getCacheDir()
218-
{
219-
return $cacheDir;
220-
}
221-
222-
public function getRootDir()
223-
{
224-
return $rootDir;
225-
}
226-
227-
public function getLogDir()
228-
{
229-
return $logDir;
230-
}
231-
232-
protected function getContainerClass()
233-
{
234-
return $containerClass;
235-
}
236-
237-
protected function buildContainer()
238-
{
239-
\$container = parent::buildContainer();
240-
241-
// filter container's resources, removing reference to temp kernel file
242-
\$resources = \$container->getResources();
243-
\$filteredResources = array();
244-
foreach (\$resources as \$resource) {
245-
if ((string) \$resource !== __FILE__) {
246-
\$filteredResources[] = \$resource;
247-
}
248-
}
249-
250-
\$container->setResources(\$filteredResources);
251-
252-
return \$container;
253-
}
254-
}
255-
}
256-
EOF;
257-
$this->getContainer()->get('filesystem')->mkdir($warmupDir);
258-
file_put_contents($file = $warmupDir.'/kernel.tmp', $code);
259-
require_once $file;
260-
$class = "$namespace\\$class";
261-
262-
return new $class($parent->getEnvironment(), $parent->isDebug());
263-
}
26479
}

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,6 @@ public function getConfigTreeBuilder()
6565
->info("Set true to enable support for the '_method' request parameter to determine the intended HTTP method on POST requests. Note: When using the HttpCache, you need to call the method in your front controller instead")
6666
->defaultTrue()
6767
->end()
68-
->arrayNode('trusted_proxies') // @deprecated in version 3.3, to be removed in 4.0
69-
->beforeNormalization()
70-
->always()
71-
->thenInvalid('The "framework.trusted_proxies" configuration key has been removed in Symfony 3.3. Use the Request::setTrustedProxies() method in your front controller instead.')
72-
->end()
73-
->end()
7468
->scalarNode('ide')->defaultNull()->end()
7569
->booleanNode('test')->end()
7670
->scalarNode('default_locale')->defaultValue('en')->end()

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1242,18 +1242,7 @@ private function registerSerializerConfiguration(array $config, ContainerBuilder
12421242
$chainLoader->replaceArgument(0, $serializerLoaders);
12431243
$container->getDefinition('serializer.mapping.cache_warmer')->replaceArgument(0, $serializerLoaders);
12441244

1245-
if (isset($config['cache']) && $config['cache']) {
1246-
@trigger_error('The "framework.serializer.cache" option is deprecated since Symfony 3.1 and will be removed in 4.0. Configure the "cache.serializer" service under "framework.cache.pools" instead.', E_USER_DEPRECATED);
1247-
1248-
$container->setParameter(
1249-
'serializer.mapping.cache.prefix',
1250-
'serializer_'.$this->getKernelRootHash($container)
1251-
);
1252-
1253-
$container->getDefinition('serializer.mapping.class_metadata_factory')->replaceArgument(
1254-
1, new Reference($config['cache'])
1255-
);
1256-
} elseif (!$container->getParameter('kernel.debug') && class_exists(CacheClassMetadataFactory::class)) {
1245+
if (!$container->getParameter('kernel.debug') && class_exists(CacheClassMetadataFactory::class)) {
12571246
$cacheMetadataFactory = new Definition(
12581247
CacheClassMetadataFactory::class,
12591248
array(

src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,6 @@ public function boot()
6060
{
6161
ErrorHandler::register(null, false)->throwAt($this->container->getParameter('debug.error_handler.throw_at'), true);
6262

63-
if ($this->container->hasParameter('kernel.trusted_proxies')) {
64-
@trigger_error('The "kernel.trusted_proxies" parameter is deprecated since version 3.3 and will be removed in 4.0. Use the Request::setTrustedProxies() method in your front controller instead.', E_USER_DEPRECATED);
65-
66-
if ($trustedProxies = $this->container->getParameter('kernel.trusted_proxies')) {
67-
Request::setTrustedProxies($trustedProxies, Request::getTrustedHeaderSet());
68-
}
69-
}
70-
7163
if ($this->container->getParameter('kernel.http_method_override')) {
7264
Request::enableHttpMethodParameterOverride();
7365
}

0 commit comments

Comments
 (0)
0